Skip to content

Instantly share code, notes, and snippets.

@jeremykdev
Last active December 24, 2015 00:29
Show Gist options
  • Save jeremykdev/6717125 to your computer and use it in GitHub Desktop.
Save jeremykdev/6717125 to your computer and use it in GitHub Desktop.
Log4Net configuration for a rolling file appender with a new file each day.
<log4net>
<appender name="rollFile" type="log4net.Appender.RollingFileAppender">
<file value="C:\path\log" />
<rollingStyle value="Date" />
<datePattern value="yyyy-MM-dd'.txt'" /> <!-- added .txt to end of date pattern so that the file extension txt will be used, note that .txt is escaped by single quotes -->
<appendToFile value="true" />
<staticLogFileName value="false" />
<layout type="log4net.Layout.PatternLayout">
<!-- note that &#x09; is tab -->
<!-- tab must be specified with XML escape characters -->
<conversionPattern value="%date{yyyy-MM-dd HH:mm:ss:fff}&#x09;%level&#x09;%message&#x09;%exception%newline" />
</layout>
</appender>
<root>
<!-- log DEBUG level and above-->
<level value="DEBUG" />
<!-- reference the configured appenders to write log entries to -->
<appender-ref ref="rollFile" />
</root>
</log4net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment