File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes BEA/Weblogic and the fly likes getting the logging level Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "getting the logging level" Watch "getting the logging level" New topic

getting the logging level

Sumit Deshpande
Ranch Hand

Joined: Jan 10, 2005
Posts: 38

I want to check if logging is enabled for a particular level before creating the log statement. With log4j, we can do that easily as shown below

I want to do the similar thing for NonCatalogLogger. I went through the weblogic API , but could not find any direct method for this (similar to isDebugEnabled()) . I guess, there should be some way to do it... I must be missing something.. any pointers will be highly appreciated...
Sumit Deshpande
Ranch Hand

Joined: Jan 10, 2005
Posts: 38
Hi Guys,
I found out a way to do this... any comments/ suggestions appreciated.
1) Get the serverlogger using LoggingHelper.getServerLogger() method.
2) Get the level from this logger object. It will return a variable of type Level.
3) Downcast it to WLLevel and get the logging level against the level with which we want to log.

Carol Enderlin
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
When you get your server logger back, you could use the isLoggable() method to check the level.

boolean isLoggable(Level level)
Check if a message of the given level would actually be logged by this logger.

Oddly enough, BEA's WLS 8.1 documentation suggests something entirely different.

Writing Debug Messages:

While your application is under development, you might find it useful to create and use messages that provide verbose descriptions of low-level activity within the application. You can use the DEBUG severity level to categorize these low-level messages. All DEBUG messages that your application generates are sent to the WebLogic Server log file. (Unlike Log4j, which is a third-party logging service that enables you to dynamically exclude log messages based on level of severity, the WebLogic Server log includes all levels of messages that your application generates.)

You also can configure the WebLogic Server to send DEBUG messages to standard out. For more information refer to "Specifying Which Messages a Server Sends to Standard Out" in the Administration Console Online Help.

If you use the DEBUG severity level, we recommend that you create a "debug mode" for your application. For example, your application can create an object that contains a boolean value. To enable or disable the debug mode, you toggle the value of the boolean. Then, for each DEBUG message, you can create a wrapper that outputs the message only if your application's debug mode is enabled.

For example, the following code can produce a debug message:

private static boolean debug = Boolean.getBoolean("my.debug.enabled");
if (debug) {
mylogger.debug("Something debuggy happened");

You can use this type of wrapper both for messages that use the message catalog framework and that use the NonCatalogLogger API.

To enable your application to print this message, you include the following Java option when you start the application's JVM:


I agree. Here's the link:
subject: getting the logging level
It's not a secret anymore!