You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Remko Popma (JIRA)" <ji...@apache.org> on 2015/10/24 17:40:27 UTC

[jira] [Resolved] (LOG4J2-873) Omitting display-name element in web.xml causes incorrect log4j initialization

     [ https://issues.apache.org/jira/browse/LOG4J2-873?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Remko Popma resolved LOG4J2-873.
--------------------------------
    Resolution: Fixed

Fixed in master in commits d17a1d3f and bbcb663a.

If no <display-name> is configured, log4j will now use the servlet context path of the web application as the logger context name.

Please verify and close.

> Omitting display-name element in web.xml causes incorrect log4j initialization
> ------------------------------------------------------------------------------
>
>                 Key: LOG4J2-873
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-873
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Web/Servlet
>    Affects Versions: 2.0.2
>            Reporter: Martin Dickins
>            Assignee: Remko Popma
>             Fix For: 2.5
>
>
> The initializeNonJndi method in Log4jWebInitializerImpl uses servletContext.getServletContextName() to get a context name (if the name hasn't been defined using log4jContextName). getServletContextName() returns the name as specified in the <display-name> element in web.xml, but that is optional.
> If neither <display-name> nor log4jContextName is defined, this results in the servletContext not being set, so the WebLookup doesn't work. The following error is displayed on the console:
> {quote}
> No Log4j context configuration provided. This is very unusual.
> {quote}
> It should use some sort of default. Probably the name of the war file or context file, if there's a generic way of getting that.
> ----
> Follow-up: as noted below, it is more than just WebLookup that fails if this happens. Log4j is initialized incorrectly: logging will work, but when the web application is stopped the logging context is not stopped, causing Tomcat to complain about Threads not being stopped and ThreadLocals not being cleaned up.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org