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 "Brian Saville (JIRA)" <ji...@apache.org> on 2015/03/06 20:26:38 UTC

[jira] [Created] (LOG4J2-973) log4j.configurationFile doesn't work properly if no log4j2.xml in classpath

Brian Saville created LOG4J2-973:
------------------------------------

             Summary: log4j.configurationFile doesn't work properly if no log4j2.xml in classpath
                 Key: LOG4J2-973
                 URL: https://issues.apache.org/jira/browse/LOG4J2-973
             Project: Log4j 2
          Issue Type: Bug
    Affects Versions: 2.2, 2.1, 2.0.2
         Environment: CentOS 6.2 x64
            Reporter: Brian Saville


h2. TL;DR:
Adding a log4j2.xml file, even if it contained bad configuration, caused the {{log4j.configurationFile}} system property to be used correctly.

h2. Long description:

I beat my head against the wall for several hours trying to figure this out, so I thought I'd document and file a bug against it since I don't think it's proper behavior.  If nothing else is done at least a doc change is in order.

I was *not* including a log4j2.xml file on the classpath at all, but instead just defined the {{log4j.configurationFile}} system property as an external file (as documented).  The logging configuration consisted of a single file appender with a root logger and one or more other loggers.  I did not configure any console appenders.  I didn't see anything in the docs stating that you need a file on the classpath in addition to this external file.

After starting, log4j2 reported (through the status logger) that it found the file and configured all appenders correctly, and even said it started the configuration and stopped the default configuration correctly.  However, ALL logging output was printed to stdout only.  At times it created the logging file it was actually supposed to go to (per file appender configuration), but this file was always empty.  Additionally, it seemed to not really load the logger configuration, as I saw everything INFO level and above in there, so it didn't seem like it was even the default configuration.

Finally I decided to try adding the same logging config file into the classpath without using the system property and external logging config file, and it worked perfectly.  To top it all off, adding back in the system property ({{log4j.configurationFile}}) to point to a different logging configuration file on the filesystem worked at this point.

I tested this with log4j 2.0.2, 2.1, and 2.2 while I was debugging it, and all exhibited the same behavior.

There is someone on SO that experienced [roughly the same issue|http://stackoverflow.com/questions/28755518/log4j2-nothing-logged-in-file], and I'll add comment shortly linking it back to this ticket just in case.



--
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