c# - Log4net doesn't write to file -
i want add new log file.this appender:
<appender name="rollingfileappender" type="log4net.appender.rollingfileappender"> <file value="mylogfile.txt"/> <appendtofile value="true"/> <rollingstyle value="size"/> <maxsizerollbackups value="5"/> <maximumfilesize value="10mb"/> <staticlogfilename value="true"/> <filter type="log4net.filter.stringmatchfilter"> <stringtomatch value="test"/> </filter> <filter type="log4net.filter.stringmatchfilter"> <stringtomatch value="error"/> </filter> <filter type="log4net.filter.denyallfilter"/> <layout type="log4net.layout.patternlayout"> <conversionpattern value="%date [%thread] %level %logger - %message%newline%exception"/> </layout> </appender> <root> <level value="all"/> <appender-ref ref="rollingfileappender"/> </root>
and on class add
[assembly: xmlconfigurator(watch = true)]
and add access file but: log4net doesn't write file. why?
log4net fails silently when there's problem. design conceit no logging preferable taking down application. figure out what's wrong, turn on log4net's internal debugging adding key [app/web].config file:
<appsettings> <add key="log4net.internal.debug" value="true"/> </appsettings>
the debug messages written console or system.diagnostics.trace
system. more details phill haack @ http://haacked.com/archive/2006/09/26/log4net_troubleshooting.aspx/
there number of reasons log4net might fail. permissions problems on log file directory, starters (especially true server processes, running under restricted set of permissions security).
Comments
Post a Comment