Tuesday 15 September 2015

log4j - Why i am getting the Warn Messages also in my logger when configured to get from INFO Level -


I have this log4j.xml file that should be logged only from the INFO level, but I also get Warne level in my logs having had .

  & lt ;? XML version = "1.0" encoding = "UTF-8"? & Gt; & Lt ;! DOCTYPE log4j: Configuration system "log4j.dtd" & gt; & Lt; Log4j: Configuration xmlns: log4j = "http://jakarta.apache.org/log4j/" & gt; & Lt; Episode class = "org.apache.log4j.RollingFileAppender" name = "FILE" & gt; & Lt; Param value = "D: \\ RAM \\ tst.log" name = "file" /> & Lt; Param value = "10" name = "max back index" /> & Lt; Param value = "200MB" name = "maxfile size" /> & Lt; Layout class = "org.apache.log4j.PatternLayout" & gt; & Lt; Param value = "% d [% t]% -5p (% F: & amp; lift;% M & amp;;% L) -% m% n" name = "conversion bar" / & gt; & Lt; / Layout & gt; & Lt; / Appender & gt; & Lt; Episode class = "com.Log4JCustomAppender" name = "CUSTAPPEN" & gt; & Lt; Layout class = "org.apache.log4j.PatternLayout" & gt; & Lt; Param value = "% d [% t]% -5p (% F: & amp; lift;% M & amp;;% L) -% m% n" name = "conversion bar" / & gt; & Lt; / Layout & gt; & Lt; / Appender & gt; & Lt; Episode class = "org.apache.log4j.AsyncAppender" name = "ASYNC" & gt; & Lt; Param name = "blocked" value = "wrong" /> & Lt; Param name = "buffer size" value = "1000" /> & Lt; Append-riff ref = "custapin" /> & Lt; / Appender & gt; & Lt; Root & gt; & Lt; Level value = "INFO" /> & Lt; Epander-Reef Ref = "FILE" /> & Lt; Appender-Riff Referee = "ASVNC" /> & Lt; / Root & gt; & Lt; / Log4j: Configuration & gt;   

This is the output coming in my custom appender and rolling file app maker

  LOgged One is 2013-06-23 01: 05: 55,954 [Main] FATAL (Hi. Java: & lt; main & gt; 14) - This is a fatal message Logged One is the 2013-06-23 01: 05: 55,965 [Main] Warne (Hi. Java: 
: 15) - This one Warning message

Please tell me how to avoid this.

This behavior is normal. Setting up a logger at a specific level price indicates that you want all levels of that level and above.

Levels:

  • TRACE
  • DEBUG
  • INFO
  • Error < Li> FATAL
  • OFF

    If you want only the INFO level, you must use the filter on your attendees:

      & lt; Filter type = "org.apache.log4j.varia.LevelMatchFilter" & gt; & Lt; AcceptOnMatch value = "true" /> & Lt; LevelToMatch value = "INFO" /> & Lt; / Filter & gt; & Lt; Filter type = "org.apache.log4j.varia.DenyAllFilter" />    

No comments:

Post a Comment