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

Kurt Lehrke updated LOG4J2-192:
-------------------------------

    Attachment: TestEnvVar.java
                log4j2.xml

I have this same problem. I wanted to reference an environment variable in my 
FileAppender's fileName.  

I've attached two files used to reproduce the issue.  I've used the Windows 
environment variable TEMP as an example.  I've also set debug points in the 
EnvironmentLookup class.  It doesn't seem to hit it.  

Below is the exception produced:

{code}ERROR StatusLogger FileManager (${env:TEMP}/log/activity.log) 
java.io.FileNotFoundException: ${env:TEMP}\log\activity.log (The filename, 
directory name, or volume label syntax is incorrect)
ERROR StatusLogger Unable to invoke method createAppender in class 
org.apache.logging.log4j.core.appender.FileAppender for element File 
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at 
org.apache.logging.log4j.core.config.BaseConfiguration.createPluginObject(BaseConfiguration.java:738)
        at 
org.apache.logging.log4j.core.config.BaseConfiguration.createConfiguration(BaseConfiguration.java:504)
        at 
org.apache.logging.log4j.core.config.BaseConfiguration.createConfiguration(BaseConfiguration.java:496)
        at 
org.apache.logging.log4j.core.config.BaseConfiguration.doConfigure(BaseConfiguration.java:161)
        at 
org.apache.logging.log4j.core.config.BaseConfiguration.start(BaseConfiguration.java:119)
        at 
org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:271)
        at 
org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:287)
        at 
org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:139)
        at 
org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:78)
        at 
org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:33)
        at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:359)
        at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:318)
        at TestEnvVar.<clinit>(TestEnvVar.java:42)
Caused by: java.lang.IllegalStateException: Unable to create a manager
        at 
org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:72)
        at 
org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:49)
        at 
org.apache.logging.log4j.core.appender.FileManager.getFileManager(FileManager.java:64)
        at 
org.apache.logging.log4j.core.appender.FileAppender.createAppender(FileAppender.java:130)
        ... 17 more

ERROR StatusLogger Null object returned for File in appenders
ERROR StatusLogger Unable to locate appender ActivityAppender for logger {code}
                
> ${env:...} is not replaced in fileName
> --------------------------------------
>
>                 Key: LOG4J2-192
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-192
>             Project: Log4j 2
>          Issue Type: Bug
>    Affects Versions: 2.0-beta4
>            Reporter: Tom Hegermann
>            Priority: Minor
>         Attachments: log4j2.xml, TestEnvVar.java
>
>
> The variable ${env:...} is not replaced in the fileName attribute in 
> RollingFileAppender whereas it is replaced in the attribute filePattern 
> correctly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to