从log4net生成相同的文件

时间:2015-07-22 14:46:52

标签: log4net log4net-configuration log4net-appender

Similar question to here but slightly different

与附加的链接一样,我试图让log4net输出到多个(x2)文件。 与链接相反,我希望将相同的信息发送到这两个文件。由于某种原因,只生成第一个日志文件(Logs.log)而不生成第二个(LogsTest.log)

有人可以为我发光吗?

<log4net>
        <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
        <file value="Logs.log" />
        <appendToFile value="true" />
        <rollingStyle value="Size" />
        <threshold value="INFO" />
        <filter type="log4net.Filter.LevelRangeFilter">
            <levelMin value="INFO" />
            <levelMax value="OFF" />
        </filter>
        <maxSizeRollBackups value="30" />
        <maximumFileSize value="50MB" />
        <staticLogFileName value="true" />
        <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="%date [%thread] %-5level %logger %P{url} %P{usr} %P{addr} – %message%newline" />
        </layout>
    </appender>
  <appender name="RollingFileAppender1" type="log4net.Appender.RollingFileAppender">
    <file value="LogsTest.log" />
    <appendToFile value="true" />
    <rollingStyle value="Size" />
    <threshold value="INFO" />
    <filter type="log4net.Filter.LevelRangeFilter">
      <levelMin value="INFO" />
      <levelMax value="OFF" />
    </filter>
    <maxSizeRollBackups value="30" />
    <maximumFileSize value="50MB" />
    <staticLogFileName value="true" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date [%thread] %-5level %logger %P{url} %P{usr} %P{addr} – %message%newline" />
    </layout>
  </appender>
    <logger name="PlaceGen">
        <level value="ALL" />
        <appender-ref ref="RollingFileAppender" />
      <appender-ref ref="RollingFileAppender1" />
    </logger>
</log4net>

1 个答案:

答案 0 :(得分:0)

让本地运营商首先重启应用程序会很聪明