log4net的不写入文件 [英] Log4net doesn't write to file

查看:461
本文介绍了log4net的不写入文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要添加新日志文件。这个是我的appender:



<预类=郎咸平的XML prettyprint-覆盖> <附加器NAME =RollingFileAppender进行TYPE =log4net.Appender.RollingFileAppender>
<文件值=mylogfile.txt/>
< appendToFile值=真/>
< rollingStyle值=大小/>
< maxSizeRollBackups值=5/>
< maximumFileSize值=10MB/>
< staticLogFileName值=真/>
<滤波器类型=log4net.Filter.StringMatchFilter>
< stringToMatch值=测试/>
< /滤光器>
<滤波器类型=log4net.Filter.StringMatchFilter>
< stringToMatch值=错误/>
< /滤光器>
<滤波器类型=log4net.Filter.DenyAllFilter/>
<布局类型=log4net.Layout.PatternLayout>
< conversionPattern值=%DATE [%线程]%的水平记录仪% - %讯息%换行符%的异常/>
< /布局>
< /附加器>
<根和GT;
<电平值=全部/>
<附加目的地-REF REF =RollingFileAppender进行/>
< /根>

和上我的课我想补充

  [汇编:XmlConfigurator(手表= TRUE)] 

和我添加访问大家的文件,但:log4net的不写入文件。为什么呢?


解决方案

log4net的失败默默时,有一个问题。设计自负是没有记录最好采取关闭应用程序。要弄清楚什么是错的,打开log4net的内部调试中加入这关键是你的[应用程序/网络] config文件:

  <&的appSettings GT; 
<添加键=log4net.Internal.DebugVALUE =真/>
< /的appSettings>



调试消息将被写入到控制台或 System.Diagnostics程序.Trace 系统。从菲尔·哈克更多细节在 http://haacked.com/archive/2006/09/26/Log4Net_Troubleshooting的.aspx /



有任何原因log4net的可能会失败。在日志文件目录的权限问题,起动器(用于服务器进程,在自己可能的一组有限的安全权限下运行尤其如此)。


I want add new log to file.this is my 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 my class I add

[assembly: XmlConfigurator(Watch = true)]

and I add access everyone for the file but: log4net doesn't write to file. Why?

解决方案

Log4net fails silently when there's a problem. The design conceit is that no logging is preferable to taking down the application. To figure out what's wrong, turn on Log4net's internal debugging by adding this key to your [app/web].config file:

<appSettings>
  <add key="log4net.Internal.Debug" value="true"/>
</appSettings>

The debug messages will be written to the console or to the System.Diagnostics.Trace system. More details from Phill Haack at http://haacked.com/archive/2006/09/26/Log4Net_Troubleshooting.aspx/

There are any number of reasons Log4net might fail. Permissions problems on the log file directory, for starters (especially true for server processes, where your likely running under a restricted set of permissions for security).

这篇关于log4net的不写入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆