-1

在本地机器 log4net 写入事件日志,在服务器上它只创建文件但它不写它。
它不能是权限,因为它会创建文件......

有什么建议吗?

<configSections>
   <section name="log4net" type="log4net.Config.Log4NetConfigurationS``ectionHandler,log4net"/>
   <section name="activerecord" type="Castle.ActiveRecord.Framework.Config.ActiveRecordSectionHandler, Castle.ActiveRecord"/>
</configSections>


<log4net>
    <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
            <file value="C:\Logs\Services"/>
            <appendToFile value="true"/>
            <staticLogFileName value="false"/>
            <rollingStyle value="Composite"/>
            <datePattern value="yyyyMMdd.lo\g"/>
            <maxSizeRollBackups value="5"/>
            <maximumFileSize value="100MB"/>
            <layout type="log4net.Layout.PatternLayout">
                    <conversionPattern value="%newline %date [%thread] %-5level %logger - %message%newline"/>
           </layout>
    </appender>
    <root>
          <!-- priority value can be set to ALL|INFO|WARN|ERROR -->
      <level value="ALL"/>
      <appender-ref ref="RollingLogFileAppender"/>
      </root>
</log4net>

编辑:我可以给你更多信息

在 LOG4NET 的 DEBUG MODE 上它写在服务器上,我可以看到所有的 DEBUG LOG

并以这些行结束

log4net: Type = [3], r0 = [19700101.log], r1 = [19700102.log]  
log4net: curSizeRollBackups starts at [0]  
log4net: reated Appender [RollingLogFileAppender]  
log4net: Adding appender named [RollingLogFileAppender] to logger [root]  
log4net: Hierarchy Threshold []  
log4net: Shutdown called on Hierarchy [log4net-default-repository]
4

1 回答 1

1

除非您发布了错误的配置,否则您没有任何 EventLogAppender。

尝试添加:

<log4net>
 <appender name="eventlog" type="log4net.Appender.EventLogAppender">
  <param name="ApplicationName" value="yourappname" />
  <param name="LogName" value="yourlognameoneventlog" />
  <param name="Threshold" value="all" />
  <layout type="log4net.Layout.PatternLayout">
    <param name="ConversionPattern" value="%m%n" />
  </layout>
 </appender>

 <root>
      <!-- priority value can be set to ALL|INFO|WARN|ERROR -->
  <level value="ALL"/>
  <appender-ref ref="RollingLogFileAppender"/>
  <appender-ref ref="eventlog" />
 </root>
</log4net>

并根据您的需要更改“ApplicationName”和“LogName”值。

于 2012-05-24T12:12:59.673 回答