You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by Shireesh Thanneru <th...@yahoo.com> on 2005/11/03 01:37:11 UTC

How to get the log level and other config info programmatically

How do I get the current log level and other config info programmatically? The ILogger interface does not define any methods or properties to do this. 
 
More specifically, if I have a logger like this:
 

private static readonly ILog logger = LogManager.getLogger();

 

How do I find out the log level of this logger (as set in the config file) and also the log level of the root logger? logger.IsInfoEnabled, etc. will suffice in most cases, but how do I find out what is the exact log level that is specified in the config file?

 

Thanks,

 

Shireesh Thanneru


RE: How to get the log level and other config info programmatically

Posted by Göran Roseen <go...@roseen.se>.
 

Well, the ILog interface does have the IsXXXXEnabled methods, which will
solve most situations where you need to address current log level.

 

i.e. 

if (log.IsDebugEnabled) 
{
     log.Debug("Entry number: " + i + " is " + entry[i]);
}

 

/Göran

 

  _____  

From: Shireesh Thanneru [mailto:thanneru@yahoo.com] 
Sent: den 3 november 2005 04:15
To: Log4NET User
Subject: Re: How to get the log level and other config info programmatically

 

Sorry, I meant  

private static readonly ILog logger = LogManager.getLogger(typeof(MyClass));

Shireesh Thanneru <th...@yahoo.com> wrote:

How do I get the current log level and other config info programmatically?
The ILogger interface does not define any methods or properties to do this. 

 

More specifically, if I have a logger like this:

 

private static readonly ILog logger = LogManager.getLogger();

 

How do I find out the log level of this logger (as set in the config file)
and also the log level of the root logger? logger.IsInfoEnabled, etc. will
suffice in most cases, but how do I find out what is the exact log level
that is specified in the config file?

 

Thanks,

 

Shireesh Thanneru


Re: How to get the log level and other config info programmatically

Posted by Shireesh Thanneru <th...@yahoo.com>.
Sorry, I meant  
private static readonly ILog logger = LogManager.getLogger(typeof(MyClass));

Shireesh Thanneru <th...@yahoo.com> wrote:
How do I get the current log level and other config info programmatically? The ILogger interface does not define any methods or properties to do this. 
 
More specifically, if I have a logger like this:
 

private static readonly ILog logger = LogManager.getLogger();

 

How do I find out the log level of this logger (as set in the config file) and also the log level of the root logger? logger.IsInfoEnabled, etc. will suffice in most cases, but how do I find out what is the exact log level that is specified in the config file?

 

Thanks,

 

Shireesh Thanneru