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 Simon Wallis <ma...@wallis.ca> on 2005/09/02 23:42:42 UTC

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