The Darkside

Shedding light on things and stuff

 
  Home :: Contact :: Syndication  :: Login
  75 Posts :: 0 Stories :: 49 Comments :: 2 Trackbacks

Ads

Archives

Post Categories

Open Source Projects

Other Blogs

This is part 3 of 3 of the article started here.
 
In part 1, I made reference to the string/type that could get passed to the GetLogger factory method. This parameter can be useful when you only want to get specific information logged from a class and not everything logged in an application. An example of this can be when your application is in production, you’ve changed the root level to warning or error, but you need debug information on a specific issues that revolves around a single class.
 
Revisiting the line that creates the logger, you can change it to:
 
public static readonly ILog _log = LogManager.GetLogger(typeof(MyClass));
 
where MyClass is the class you declare the static log variable. In the <log4net> section of the configuration file, you can add the following code:
 
<logger name="MyClass" additivity="true">
    <level value="DEBUG"/>
    <appender-ref ref="RollingFile"/>
</logger>
 
As you can see, you are able to set individual levels for specific loggers, as well as the types of appenders that you want to make use of. The levels you can set are ALL, DEBUG, INFO, WARN, ERROR and CRITICAL.
posted on Friday, August 03, 2007 9:52 AM
Comments have been closed on this topic.