Log4net print DateTime / class / function call on each line

Is it possible to use log4net to automatically write the date / time and class name / function name to the beginning of each registered line?

+4
source share
1 answer

In the log4net configuration file, change the Appender section to add a PatternLayout with a custom format. The following template 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 print the fully qualified class name by changing %C{1} to %C

+6
source

All Articles