log4j logging twice

前端 未结 9 1627
眼角桃花
眼角桃花 2021-02-04 23:02

I am using log4j to log error and other system information. but come of the info logged twice at INFO level.

public static void main(final String... args) throws         


        
9条回答
  •  野性不改
    2021-02-04 23:34

    Looks like your messages are being logged once by the root logger and again by the specific logger as you may have both the appenders configured (may be at different places -in a properties file and then in code).

    This can be solved by setting additivity to false on your logger. Log4j manual mentions additivity in the Appenders and Layout section.Check that out

提交回复
热议问题