How to Re-Execute Log4j “Default Initialization Procedure”?

前端 未结 3 1500
暖寄归人
暖寄归人 2021-02-02 11:36

At runtime I often create/modify log4j Loggers, Appenders, Levels, Layouts, and time to time need to reset everything back to defaults.

Log4j

3条回答
  •  清歌不尽
    2021-02-02 12:12

    According to the documentation for the doConfigure method:

    Read configuration from a file. The existing configuration is not cleared nor reset. If you require a different behavior, then call resetConfiguration method before calling doConfigure.

    So I belive that calling LogManager.resetConfiguration() and recall PropertyConfigurator.configure() with the same files as on startup will do what you want.

    The resetConfiguration() method is documented in Hierarchy class.

提交回复
热议问题