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

Remko Popma commented on LOG4J2-921:
------------------------------------

The problem seems to be that the custom lookup always returns the same value, 
even though it is designed to return a different value on the first call 
(system startup) than subsequent calls (rollover).

I looked at the source but it seems to be doing the right thing: at every 
rollover, the header is obtained from the layout. PatternLayout.getHeader() 
returns StrSubstitutor.replace(headerString)... Is the value (the result of the 
lookup) cached anywhere?

> Allow to log some important information at the start of each new roll over 
> log file when using RollingFile Appender
> -------------------------------------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-921
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-921
>             Project: Log4j 2
>          Issue Type: Improvement
>          Components: Appenders
>    Affects Versions: 2.1
>            Reporter: Setu
>
> if someone wants to log some important information at the start of each roll 
> over log file there is no mechanism present in current version. The header 
> attribute in PatternLayout barely does the job because it logs the header at 
> the start of each system startup. 
> Example: There is a requirement to log some system properties (or any other 
> details, environment details, etc) at the each roll over so that it becomes 
> easy to determine on which environment the software is running. When tried to 
> use header attribute on a software that continuously runs on server it did 
> not work as expected instead the header was logged whenever the server got 
> restarted. 
> Also how can they key supplied in header attribute be logged with line 
> breaks. 
> Example: when using {{header="$\{java:runtime} - $\{java:vm} - $\{java:os}"}} 
> it prints all the information in same line which makes it unreadable if 
> someone wants more details. 
> Implementing a custom lookup did not help either as all it did was kept 
> logging the custom lookup key in header attribute at each system restart 
> instead of at the start of new rollover file. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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

Reply via email to