[
https://issues.apache.org/jira/browse/LOG4J2-1622?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15766832#comment-15766832
]
Remko Popma commented on LOG4J2-1622:
-------------------------------------
I am guessing you have trouble with the variables. Variables like $\{filepath}
or $\{patternTime} need to be either declared as properties in the
configuration, *or* prefixed with {{sys:}} so that Log4j 2 knows to use the
system property Lookup.
In configuration:
{code}
<Configuration status="warn">
<Properties>
<Property name="filepath">/path/to/log/directory</Property>
<Property name="patternTime">%date %level %logger %message</Property>
</Properties>
<Appenders>
<RollingFile name="RollingFile" fileName="${filepath}/app.log"
filePattern="${filepath}/logs/app-%d{yyyy-MM-dd}.log">
<PatternLayout><Pattern>${patternTime}</Pattern></PatternLayout>
<Policies><CronTriggeringPolicy schedule="0 0 0 * * ?"/></Policies>
</RollingFile>
</Appenders>
<Loggers>
<Root level="trace>
<AppenderRef ref="RollingFile" />
</Root>
</Loggers>
</Configuration>
{code}
*or* as system properties
{code}
<Configuration status="warn">
<Appenders>
<RollingFile name="RollingFile" fileName="${sys:filepath}/app.log"
filePattern="${sys:filepath}/logs/app-%d{yyyy-MM-dd}.log">
<PatternLayout><Pattern>${sys:patternTime}</Pattern></PatternLayout>
<Policies><CronTriggeringPolicy schedule="0 0 0 * * ?"/></Policies>
</RollingFile>
</Appenders>
<Loggers>
<Root level="trace>
<AppenderRef ref="RollingFile" />
</Root>
</Loggers>
</Configuration>
{code}
> how to config a DailyRollingFileAppender like log4j1.x
> ------------------------------------------------------
>
> Key: LOG4J2-1622
> URL: https://issues.apache.org/jira/browse/LOG4J2-1622
> Project: Log4j 2
> Issue Type: Question
> Components: Appenders
> Affects Versions: 2.6.2
> Reporter: Tboy
>
> like this:
> {code}
> <RollingFile name="RollingFile" fileName="${filepath}/app.log"
> filePattern="${filepath}/logs/app-%d{yyyy-MM-dd}.log">
> <PatternLayout>
> <Pattern>${patternTime}</Pattern>
> </PatternLayout>
> <Policies>
> <CronTriggeringPolicy schedule="0 0 0 * * ?"/>
> </Policies>
> </RollingFile>
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]