[
https://issues.apache.org/jira/browse/LOG4J2-921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14247799#comment-14247799
]
Ralph Goers commented on LOG4J2-921:
------------------------------------
Try using 2 '$' characters. I suspect the header string is being processed
during initial configuration before it is even passed to PatternLayout. With 2
'$' character the first will be stripped during initial configuration and then
the second will result in the value being replaced in the getHeader call.
> 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]