logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michał Sobkiewicz (JIRA) <j...@apache.org>
Subject [jira] [Commented] (LOG4J2-378) Logging generates file named ${sys on some systems
Date Thu, 30 Mar 2017 10:49:42 GMT

    [ https://issues.apache.org/jira/browse/LOG4J2-378?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15948831#comment-15948831

Michał Sobkiewicz commented on LOG4J2-378:

Hello again! My problem was caused by incorrect configuration.

What I missed is that during log4j auto initialization, {{Log4jServletContextListener}} is
being registered _after_ listeners declared within web.xml. You can reorder processing of
web-fragments by using {{<absolute-ordering>}}, but you can't make them to be processed
before web.xml (according to [Servlet 3.0 Spec|http://download.oracle.com/otndocs/jcp/servlet-3.0-fr-oth-JSpec/]
/ 8.2.2 Ordering of web.xml and web-fragment.xml / 1b).

Because of incorrect ordering, Spring's {{ContextLoaderListener#contextDestroyed}} was being
invoked after {{Log4jServletContextListener#contextDestroyed}} during server's shutdown. Nested
call to {{LogFactory.getLog}} within the former one was causing "/actual/catalina/base/logs/$\{web:contextPath\}.log"
file to be created (log4j web context was already destroyed, so $\{web:contextPath\} couldn't
be resolved).

Sorry for misleading!

> Logging generates file named ${sys on some systems
> --------------------------------------------------
>                 Key: LOG4J2-378
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-378
>             Project: Log4j 2
>          Issue Type: Bug
>    Affects Versions: 2.0-beta8, 2.0-beta9
>         Environment: Issues occurs on Win7/64 system under Tomcat 7.0.42 / Oracle JDK
1.7.0_25; fails to occur on RHEL 5.2 system under Tomcat 7.0.26 / Oracle JDK 1.7.0_03
>            Reporter: Eric Schwarzenbach
> In a webapp I'm setting a system property in my apps ServletContextListener, and using
that system property in my log4j2.xml file, like so:
> {code}
> <appender type="FastFile" name="File" fileName="${sys:catalina.home}/logs/${sys:application-name}.log">
> {code}
> On my Windows machine, a log file named "${sys." (always 0 bytes) is being created instead
of a log file with the application-name. The same war deployed on one of our linux servers
does not create a ${sys." file and instead creates a log file with the intended application-name.

> I should note that the files DO appear in the directory that sys:catalina.home should
resolve to. They appear elsewhere when I don't use sys:catalina.home so I'm quite sure that
this variable is resolving correctly and it is the sys:application-name which is the problem.

This message was sent by Atlassian JIRA

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

View raw message