如何从日志文件中删除Tomcat INFO

时间:2015-07-09 08:49:22

标签: java tomcat logging log4j log4jdbc

如何从日志文件中删除所有Tomcat INFO,但只是从我的日志文件中,我只想在控制台输出中看到INFO

1 个答案:

答案 0 :(得分:0)

这是你能做的。希望它有所帮助

#Root logger选项     log4j.rootLogger = DEBUG,stdout,file

# Redirect log messages to console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

# Redirect log messages to a log file, support file rolling.
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=C:\\log4j-application.log
log4j.appender.file.MaxFileSize=5MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
<!-- Redirect the logging to console. -->
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="true"
    xmlns:log4j='http://jakarta.apache.org/log4j/'>

    <appender name="console" class="org.apache.log4j.ConsoleAppender">
        <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" 
          value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />
        </layout>
    </appender>

    <root>
        <level value="ERROR" />
        <appender-ref ref="console" />
    </root>

</log4j:configuration>
<!-- 
Redirect the logging to a file.. -->
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="true"
    xmlns:log4j='http://jakarta.apache.org/log4j/'>

    <appender name="file" class="org.apache.log4j.RollingFileAppender">
       <param name="append" value="false" />
       <param name="maxFileSize" value="10KB" />
       <param name="maxBackupIndex" value="5" />
       <!-- For Tomcat -->
       <param name="file" value="${catalina.home}/logs/myStruts1App.log" />
       <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" 
            value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />
       </layout>
    </appender>

    <root>
        <level value="INFO" />
        <appender-ref ref="file" />
    </root>

</log4j:configuration>