How to properly shutdown log4j2

前端 未结 3 1005
轻奢々
轻奢々 2020-12-06 10:36

If one is not running inside a web application, what is the proper way to shutdown Log4j2? I only see a noop LogManager.shutdown()

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-06 11:23

    Log4j-Web library is the preferred way to properly clean-up resources in Web-application.

    To enable it, add such a dependency to your pom.xml

    
        org.apache.logging.log4j
        log4j-web
        ${log4j2.version}
        runtime
    
    

    It will work 'out-of-the box' in Servlet 3.* environment. If you're using older Servlet specification, details how to enable proper cleaning for log4j2 are available here: https://logging.apache.org/log4j/2.x/manual/webapp.html

提交回复
热议问题