While it is not difficult to setup different log files, each with a different conversionPattern, per level, I would like to have minimal logging for all but errors, where I'd like a detailed log entry. Here's a snippet of my current configuration:
<appender name="WarningsAndBelowFileAppender" type="log4net.Appender.FileAppender">
<file value="log.txt" />
<appendToFile value="false" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%m%n" />
</layout>
<filter type="log4net.Filter.LevelRangeFilter">
<levelMax value="WARN" />
</filter>
</appender>
<appender name="ErrorsFileAppender" type="log4net.Appender.FileAppender">
<file value="errors.txt" />
<appendToFile value="false" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%d [%t] %-5p %c [%x] - %m%n" />
</layout>
<threshold value="ERROR" />
</appender>
I'd love to have both of these configurations go into a single log file, just have different conversionPatterns for each. Can this be done?
you can't do it within the config file but you can make it with pattern layout converter.
See information here
This should be the converted code:
And here is the config file: