Looking up a system property specified in a log4j v1 properties file
Natasha D'Silva <[email protected]>
| Newsgroups | gmane.comp.jakarta.log4j.user |
|---|---|
| Message-ID | <PH0PR15MB444882B2AD63F1038FD3480C94039@PH0PR15MB4448.namprd15.prod.outlook.com> |
I'm using log4j v2, the log4j v1 bridge and a v1 log4j.properties file that specifies an appender like this:
log4j.appender.KRFTRACE=${abc.def.log4j.appender.KRFTRACE}
log4j.rootLogger=ALL, KRFTRACE
I set the system property abc.def.log4j.appender.KRFTRACE to the appropriate class.
Previously, with log4j v2.13.3, this worked, you can see from the logs:
DEBUG StatusLogger Parsing for [root] with value=[ALL, KRFTRACE].
DEBUG StatusLogger Level token is [ALL].
DEBUG StatusLogger Logger root level set to ALL
DEBUG StatusLogger Parsing appender named "abc.def.TRACE".
DEBUG StatusLogger Adding appender named [KRFTRACE] to loggerConfig [].
DEBUG StatusLogger Level token is [ALL].
...
DEBUG StatusLogger Finished configuring.
But in v2.17.1, I get this error:
DEBUG StatusLogger Parsing for [root] with value=[ALL, KRFTRACE].
DEBUG StatusLogger Level token is [ALL].
DEBUG StatusLogger Logger root level set to ALL
DEBUG StatusLogger Parsing appender named "KRFTRACE".
ERROR StatusLogger Unable to create Appender ${abc.def.log4j.appender.KRFTRACE} due to ClassNotFoundException:${abc.def.log4j.appender.KRFTRACE}
Instead of checking the system property for the class name, the logger tries to use the lookup key "{abc.def.log4j.appender.KRFTRACE} " as the class name.
I have confirmed that the system property is set correctly.
I know from the doc that in v2 system properties are specified with the "${sys:}" prefix, but up until now it seemed to support both the {} and {sys:} prefix for system properties. Are both supported or was it working in 2.13.3 by accident?
It isn't trivial to experiment with changing the properties file so I wanted to ask if this is a new bug or the previous behaviour in 2.13.3 was wrong and the properties file should always have used the "${sys:} prefix.
Thank you.