Reputation: 4142
Is there any way using log4net to automatically write date/time and class name/function name to the start of each logged line?
Upvotes: 4
Views: 1295
Reputation: 62564
In the log4net
configuration file modify Appender section by adding a PatternLayout with custom format. Following pattern will output DateTime ClassName.MethodName
<appender name="DebugOut"
type="log4net.Appender.OutputDebugStringAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date{MM/dd/yy HH:mm} %C{1}.%M" />
</layout>
</appender>
You can output fully qualified name of class by changing %C{1}
to %C
Upvotes: 6