logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Remko Popma (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (LOG4J2-671) Property using ${date:} is evaluated multiple times across appenders
Date Sun, 18 Oct 2015 15:07:05 GMT

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

Remko Popma updated LOG4J2-671:
-------------------------------
    Description: 
At the top of my log4j2.xml config I have the following properties:

{code}
<Properties>
    <Property name="log_date">${date:yyyy-MM-dd'T'HHmmssSSS></Property>
    <Property name="log_path">log/${log_date}</Property>
</Properties>
{code}

I would like to use the "log_path" property as the root log directory for all my appenders.
By including a timestamp in "log_path" I can distinguish between multiple runs of my application.
My appenders refer to "log_path" in the following way:

{code}
<RollingRandomAccessFile name="ApplicationLog" append="true"
        fileName="${log_path}/application.log"
        filePattern="${log_path}/application.log-$${date:yyyy-MM-dd'T'HHmmssSSS}.gz">
..snip..
</RollingRandomAccessFile>
{code}

I have several such appenders, and I'd like them to all refer to the same "log_path" value.
Unfortunately, it seems that the property gets re-evaluated for each appender, so I end up
with multiple log directories on a given run of my application. Below is an example:

ls -al log/
total 20
drwxr-xr-x 5 rveitch rveitch 4096 Jun 16 14:12 .
drwxrwxr-x 6 rveitch rveitch 4096 Jun 16 13:18 ..
drwxrwxr-x 2 rveitch rveitch 4096 Jun 16 14:12 2014-06-16T141225420
drwxrwxr-x 2 rveitch rveitch 4096 Jun 16 14:12 2014-06-16T141225462
drwxrwxr-x 2 rveitch rveitch 4096 Jun 16 14:12 2014-06-16T141225501

Is there anyway to evaluate a property once, such that the value is frozen for re-use across
appenders? Is there an alternative approach to generate a timestamp which I can use as a part
of a common log directory path?

  was:
At the top of my log4j2.xml config I have the following properties:

<Properties>
		<Property name="log_date">${date:yyyy-MM-dd'T'HHmmssSSS}</Property>
		<Property name="log_path">log/${log_date}</Property>
	</Properties>

I would like to use the "log_path" property as the root log directory for all my appenders.
By including a timestamp in "log_path" I can distinguish between multiple runs of my application.
My appenders refer to "log_path" in the following way:

<RollingRandomAccessFile name="ApplicationLog" append="true"
			fileName="${log_path}/application.log"
			filePattern="${log_path}/application.log-$${date:yyyy-MM-dd'T'HHmmssSSS}.gz">
..snip..
		</RollingRandomAccessFile>

I have several such appenders, and I'd like them to all refer to the same "log_path" value.
Unfortunately, it seems that the property gets re-evaluated for each appender, so I end up
with multiple log directories on a given run of my application. Below is an example:

ls -al log/
total 20
drwxr-xr-x 5 rveitch rveitch 4096 Jun 16 14:12 .
drwxrwxr-x 6 rveitch rveitch 4096 Jun 16 13:18 ..
drwxrwxr-x 2 rveitch rveitch 4096 Jun 16 14:12 2014-06-16T141225420
drwxrwxr-x 2 rveitch rveitch 4096 Jun 16 14:12 2014-06-16T141225462
drwxrwxr-x 2 rveitch rveitch 4096 Jun 16 14:12 2014-06-16T141225501

Is there anyway to evaluate a property once, such that the value is frozen for re-use across
appenders? Is there an alternative approach to generate a timestamp which I can use as a part
of a common log directory path?


> Property using ${date:} is evaluated multiple times across appenders
> --------------------------------------------------------------------
>
>                 Key: LOG4J2-671
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-671
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Configurators
>    Affects Versions: 2.0-rc1
>         Environment: OS: Ubuntu 12.04
>            Reporter: Robert Veitch
>
> At the top of my log4j2.xml config I have the following properties:
> {code}
> <Properties>
>     <Property name="log_date">${date:yyyy-MM-dd'T'HHmmssSSS></Property>
>     <Property name="log_path">log/${log_date}</Property>
> </Properties>
> {code}
> I would like to use the "log_path" property as the root log directory for all my appenders.
By including a timestamp in "log_path" I can distinguish between multiple runs of my application.
My appenders refer to "log_path" in the following way:
> {code}
> <RollingRandomAccessFile name="ApplicationLog" append="true"
>         fileName="${log_path}/application.log"
>         filePattern="${log_path}/application.log-$${date:yyyy-MM-dd'T'HHmmssSSS}.gz">
> ..snip..
> </RollingRandomAccessFile>
> {code}
> I have several such appenders, and I'd like them to all refer to the same "log_path"
value. Unfortunately, it seems that the property gets re-evaluated for each appender, so I
end up with multiple log directories on a given run of my application. Below is an example:
> ls -al log/
> total 20
> drwxr-xr-x 5 rveitch rveitch 4096 Jun 16 14:12 .
> drwxrwxr-x 6 rveitch rveitch 4096 Jun 16 13:18 ..
> drwxrwxr-x 2 rveitch rveitch 4096 Jun 16 14:12 2014-06-16T141225420
> drwxrwxr-x 2 rveitch rveitch 4096 Jun 16 14:12 2014-06-16T141225462
> drwxrwxr-x 2 rveitch rveitch 4096 Jun 16 14:12 2014-06-16T141225501
> Is there anyway to evaluate a property once, such that the value is frozen for re-use
across appenders? Is there an alternative approach to generate a timestamp which I can use
as a part of a common log directory path?



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


Mime
View raw message