I can log info messages without a problem, but can't figure out how to log verbose messages. Any help would be welcomed.
My problem is:
loggingEvent.Level can be checked in the Format function. The possible values are amongst others, Info, Debug, Error, Verbose. There are more, but these are the ones I'll be using mostly.
The actual log object only has the following methods:
Log.Info
Log.Debug
Log.Warn
Log.Error
As you can see - no verbose!
So how can I Log a verbose message, this is different to debug
Thanks in advance
In software, verbose logging is the practice of recording to a persistent medium as much information as you possibly can about events that occur while the software runs. It's also worth mentioning that verbose logging is generally a mode that you can toggle on and off.
Verbose logging is a type of computer logging method that involves more information than the standard or typical logging process. Typically, users can turn on verbose logging features to get more information about a system.
You can add a Verbose (or Trace level) to log4net by using extension methods. This is what I'm using:
public static class ILogExtentions
{
public static void Trace(this ILog log, string message, Exception exception)
{
log.Logger.Log(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType,
log4net.Core.Level.Trace, message, exception);
}
public static void Trace(this ILog log, string message)
{
log.Trace(message, null);
}
public static void Verbose(this ILog log, string message, Exception exception)
{
log.Logger.Log(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType,
log4net.Core.Level.Verbose, message, exception);
}
public static void Verbose(this ILog log, string message)
{
log.Verbose(message, null);
}
}
Usage example:
public class ClientDAO
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(ClientDAO));
public void GetClientByCode()
{
log.Trace("your verbose message here");
//....
}
}
Source:
http://www.matthewlowrance.com/post/2010/07/14/Logging-to-Trace-Verbose-etc-with-log4net.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With