logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicko Cadell" <ni...@neoworks.com>
Subject RE: custom logging level
Date Sat, 03 Sep 2005 10:50:23 GMT

If you want to use your custom level name in the config file then you
need to define the level in the config file. Add the following to the
top of your <log4net> section:

  <name value="ACTIVITY" />
  <value value="40000" />

Then you can use the ACTIVITY level in your config file.


> -----Original Message-----
> From: Simon Wallis [mailto:mailing@wallis.ca] 
> Sent: 02 September 2005 22:43
> To: log4net-user@logging.apache.org
> Subject: custom logging level
> Hi, I want to add a new custom logging level, called 
> ACTIVITY, to record user activity. It can have the same level 
> as INFO, but it must have its own name so that it's easily 
> distinguishable and so I can record ACTIVITY events to a 
> separate log file.
> Since the log4net Level class is sealed, I cannot override it 
> in my log4netExtensions project. Therefore, in my LogExtImpl 
> class where I implement various Activity() methods and 
> IsActivityEnabled(), I have a private variable like this:
> private Level ACTIVITY = new Level(Level.INFO.Value, "ACTIVITY");
> If I do this, however, the configuration will not understand 
> any references to a level of "ACTIVITY". It will successfully 
> log ACTIVITY events along with INFO events, but I cannot 
> handle ACTIVITY events in any special way since the config 
> does not know about this level.
> I also implemented a custom log level called TRACE, but this 
> worked fine since it already exists in the Level class, and 
> my Trace() methods in LogExtImpl can reference that (as the 
> example code in the distribution demonstrates).
> So how can I accomplish what I'm trying to do with a custom 
> log level that doesn't exist in the Level class??
> Thanks,
> Simon. 
> ________________________________________________________________
> Sent via the WebMail system at wallis.ca

View raw message