c# - How to onfigure Log4Net to rolling everyday? -
i want configure log4net
rolling every day, mean want take log everyday in new file, config log4net
in app.config
:
<?xml version="1.0" encoding="utf-8"?> <configuration> <configsections> <section name="log4net" type="log4net.config.log4netconfigurationsectionhandler, log4net" /> </configsections> <log4net> <root> <level value="debug" /> <appender-ref ref="fileappender" /> </root> <appender name="fileappender" type="log4net.appender.rollingfileappender"> <file type="log4net.util.patternstring" value="e:/mylog_" /> <staticlogfilename value="false" /> <appendtofile value="true" /> <rollingstyle value="date" /> <datepattern value="yyyy.mm.dd'.log'" /> <lockingmodel type="log4net.appender.fileappender+minimallock" /> <layout type="log4net.layout.patternlayout"> <conversionpattern value="%date{dd/mm/yyyy hh:mm:ss.fff} - %level - %message%newline" /> </layout> </appender> </log4net> <startup> <supportedruntime version="v4.0" sku=".netframework,version=v4.5" /> </startup> </configuration>
but not work, problem?
your date format appears incorrect. if use same date , time formatters microsoft (i don't know if sure, they're universal), mm
represents minutes, not days.
per log4net documentation, try changing lowercase mm
uppercase mm
.
<datepattern value="yyyy.mm.dd'.log'" />
Comments
Post a Comment