I have wrapped Log4net in a static wrapper and want to log
loggingEvent.LocationInformation.MethodName
loggingEvent.LocationInformation.ClassName
I will just write more code of the correct answer of Claus
In the wrapper class
public static class Logger
{
private static readonly ILogger DefaultLogger;
static Logger()
{
defaultLogger = LoggerManager.GetLogger(Assembly.GetCallingAssembly(), "MyDefaultLoggger"); // MyDefaultLoggger is the name of Logger
}
public static void LogError(object message)
{
Level errorLevel = Level.Error;
if (DefaultLogger.IsEnabledFor(errorLevel))
{
DefaultLogger.Log(typeof(Logger), errorLevel, message, null);
}
}
public static void LogError(object message, Exception exception)
{
Level errorLevel = Level.Error;
if (DefaultLogger.IsEnabledFor(errorLevel))
{
DefaultLogger.Log(typeof(Logger), errorLevel, message, exception);
}
}
and so on for the rest of methods.
in web.config or app.config log4net.Layout.PatternLayout you can use some Conversion Patterns like:
%location %method %line