如何将特定的日志级别记录到特定的文件中?
我想要: INFO-info-log.txt 错误-error-log.txt 调试-debug-log.txt 警告-warn-log.txt
当我将级别设置为INFO,信息,错误时,警告将被记录到INFO文件中。我无法将INFO级别转到info-log.txt。
这是我正在处理的属性文件。
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="ALL">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout>
<Pattern>%d %-5p %m%n</Pattern>
</PatternLayout>
<ThresholdFilter level="all"/>
</Console>
<RollingFile name="RollingDebugLogFile" fileName="C:\logs\app-debug.log" filePattern="app-debug-%d{MM-dd-yyyy}-%i.log.gz">
<PatternLayout>
<Pattern>%d %-5p %m%n</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="20MB"/>
</Policies>
<ThresholdFilter level="DEBUG"/>
</RollingFile>
<RollingFile name="RollinginfoLogFile" fileName="C:\logs\app-info.log" filePattern="app-info-%d{MM-dd-yyyy}-%i.log.gz">
<PatternLayout>
<Pattern>%d %-5p %m%n</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="20MB"/>
</Policies>
<ThresholdFilter level="INFO"/>
</RollingFile>
<RollingFile name="RollingErrorLogFile" fileName="C:\logs\app-error1.log" filePattern="app-error-%d{MM-dd-yyyy}-%i.log.gz">
<PatternLayout>
<Pattern>%d %-5p %m%n</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="20MB"/>
</Policies>
</RollingFile>
</Appenders>
<Loggers>
<Root name="proj" level="INFO">
<AppenderRef ref = "RollingErrorLogFile" />
</Root>
</Loggers>
</Configuration>