If you define a custom level then you can log a message using a method
like:
private static void LogActivity(log4net.ILog log, object message,
Exception ex)
{
log4net.Core.Level activityLevel =
log.Logger.Repository.LevelMap["ACTIVITY"];
log.Logger.Log(this.GetType(), activityLevel, message, ex);
}
In theory the activity level can change at any time due to
reconfiguration.
The log4net.Ext.Trace extension in the log4net download is a good
example of one way of adding extra levels and adding the methods that
you can call to log. Otherwise you need to write your own logging
methods to call the raw Logger.Log method.
Cheers,
Nicko
> -----Original Message-----
> From: tinhuty he [mailto:[EMAIL PROTECTED]
> Sent: 25 May 2006 15:49
> To: [email protected]
> Subject: Re: Custom level usage
>
> Thanks for your reply. I am still confused. As I understood
> the TRACE extension is needed for previous version of
> log4net, the latest version doesn't require user to implement
> custom extension to use a custom level. is that right?
>
>
> = = = Original message = = =
>
> You can see an example in log4net source code. Look in
> log4net extensions - they have an example for a TRACE custom
> log level.
>
> tinhuty he <[EMAIL PROTECTED]> wrote: I am using the
> version 1.2.10. I am not quite sure how to use the custom
> level. In the previous email I knew that I have to define a
> custom level in config file as follows:
>
>
>
>
>
>
> I define a log in my class as follows:
>
> protected static readonly ILog log =
> LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
>
> Now how do I log a message with "ACTIVITY" level in my code?
>
> Thanks.
>
> ___________________________________________________________
> Sent by ePrompter, the premier email notification software.
> Free download at http://www.ePrompter.com.
>
> _________________________________________________________________
> On the road to retirement? Check out MSN Life Events for
> advice on how to
> get there! http://lifeevents.msn.com/category.aspx?cid=Retirement
>
> ___________________________________________________________
> Sent by ePrompter, the premier email notification software.
> Free download at http://www.ePrompter.com.
>
> _________________________________________________________________
> Express yourself instantly with MSN Messenger! Download today
> - it's FREE!
> http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
>
>
>