apache / apache/logging-log4j2

Document isLog4jAutoShutdownDisabled to enable logging during a web application listener's contextDestroyed

Open
#2,689 2 comments 0 reactions 0 assignees View on GitHub
waiting-for-maintainer
Dominant language
Java
Stars
3.6k
Forks
1.7k
Avg merge
21h 30m
Merged PRs (30d)
27

Description

As discussed in issue [LOG4J2-1606](https://issues.apache.org/jira/browse/LOG4J2-1606), a flag was added to address the problem of log4j-web shutting down Log4j when other listeners defined in the web app still want to log messages during their contextDestroyed. However, this is not documented anywhere and it was quite difficult for me to find the solution. I suggest documenting this in [Using Log4j 2 in Web Applications](https://logging.apache.org/log4j/2.x/manual/webapp.html) or [Frequently Asked Questions](https://logging.apache.org/log4j/2.12.x/faq.html):

When your web application includes log4j-web (as it [should](https://logging.apache.org/log4j/2.x/manual/webapp.html)) and you would like to use Log4j to log messages when one of your listener's `contextDestroyed` method is called, include the following near the top of your `web.xml`:

```xml


isLog4jAutoShutdownDisabled
true


org.apache.logging.log4j.web.Log4jShutdownOnContextDestroyedListener

```

Note that for Servlet 3.x, you don't need to include your listener in your `web.xml` if it is annotated with `@WebListener`. The above solution will still work for you.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the “Using Log4j 2 in Web Applications” page and the referenced Frequently Asked Questions page. Document the isLog4jAutoShutdownDisabled context parameter, the Log4jShutdownOnContextDestroyedListener registration order, and the Servlet 3.x @WebListener case; done means users can find and follow the web.xml example to keep logging available during contextDestroyed.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.