Example of File and Folder structure
└───2018
└───May-2018_logfile.log
└───
Jun-2018_logfile.log
└───Jul-2018_logfile.log
└───Aug-2018_logfile.log
Log4net.config configuration example
<log4net>
<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender, log4net">
<file type="log4net.Util.PatternString" value="C:/logs/log4netLogs/%date{yyyy}/" />
<appendToFile value="true" />
<rollingStyle value="Date" />
<staticLogFileName value="false" />
<datePattern value="MMM-yyyy'_logfile.log'" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger %M - %message%newline%newline" />
</layout>
</appender>
<logger name="File">
<level value="All" />
<appender-ref ref="LogFileAppender" />
</logger>
</log4net>
Path Setting
<file type="log4net.Util.PatternString" value="C:/logs/log4netLogs/%date{yyyy}/%date{MMM}/" />
File Name Setting
<datePattern value="MMM-yyyy'_logfile.log'" />
Comments
Post a Comment