在我将Logstash实施到我的系统之前,我的log4net文件将在达到4MB时滚动到新的日志文件。但是现在的行为是它不会滚动到新的日志文件,而是删除日志文件中的内容并将新的日志消息附加到同一个日志文件中。似乎Logstash正在锁定log4net日志文件并阻止它滚动它。
我在这里做错了吗?或者这是Windows中的logstash的错误?
仅供参考,我使用的logstash版本是v1.4.2。
以下是logstash文件输入的代码:
input {
file {
path => "C:/Logs/*"
exclude => "*.ERROR.log"
codec => multiline {
pattern => "^(WARN|ERROR|INFO)"
negate => true
what => previous
}
}
}
以下是我的控制台应用程序的log4net配置代码:
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%-5p %d %a %5rms %-22.22c{1} %-18.18M [%t] - %m MsgEnd%n" />
</layout>
</appender>
<appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%-5p %d %a %5rms %-22.22c{1} %-18.18M [%t] - %m MsgEnd%n" />
</layout>
</appender>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="C:Logs\\APICentral.ProcessRunner.ALL.log" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="20" />
<maximumFileSize value="4MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%-5p %d %a %5rms %-22.22c{1} %-18.18M [%t] - %m MsgEnd%n" />
</layout>
</appender>
<appender name="ErrorOnlyRollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="C:\\Logs\\APICentral.ProcessRunner.ERROR.log" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="2MB" />
<staticLogFileName value="true" />
<param name="Threshold" value="ERROR" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%-5p %d %a %5rms %-22.22c{1} %-18.18M [%t] - %m MsgEnd%n" />
</layout>
<filter type="log4net.Filter.LevelRangeFilter">
<levelMin value="WARN" />
<levelMax value="ERROR" />
</filter>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="ConsoleAppender" />
<appender-ref ref="RollingLogFileAppender" />
<appender-ref ref="ErrorOnlyRollingLogFileAppender" />
</root>
</log4net>