How to set filter in the log4j.xml

后端 未结 2 1305
孤独总比滥情好
孤独总比滥情好 2021-01-04 07:15

HI,

In our web application it prints all the logs are printed like Spring and JSF jars files. Which not required for us. How can I set in the log4j.xml file to filte

2条回答
  •  萌比男神i
    2021-01-04 07:41

    You need to define the own logger and appender for your application. For example, if you need to log the trace message in com.xyz.http.RequestFilter:

    log4j.com.xyz.http.RequestFilter=TRACE, TRACE_APPEND
    
    log4j.appender.TRACE_APPEND=org.apache.log4j.RollingFileAppender
    log4j.appender.TRACE_APPEND.File=example.log
    
    log4j.appender.TRACE_APPEND.MaxFileSize=100KB
    log4j.appender.TRACE_APPEND.MaxBackupIndex=1
    
    log4j.appender.TRACE_APPEND.layout=org.apache.log4j.PatternLayout
    log4j.appender.TRACE_APPEND.layout.ConversionPattern=%p %t %c - %m%n
    

    See more at log4j official manual http://logging.apache.org/log4j/1.2/manual.html

提交回复
热议问题