Michele Preti created LOG4J2-2502:
-------------------------------------
Summary: Support ContextListener like in Logback
Key: LOG4J2-2502
URL: https://issues.apache.org/jira/browse/LOG4J2-2502
Project: Log4j 2
Issue Type: Bug
Components: Web/Servlet
Affects Versions: 2.11.1
Reporter: Michele Preti
Hi,
i'm trying to switch to Log4j from Logback.
In the configuration (the file appender), i'm using a system property that does
not exist and is created in the contextListener (the logs path is generated at
runtime and can't be set staticly in the config file)
{code:java}
<configuration debug="true">
<contextListener class="it.my.LoggerStartupListener"/>
<appender name="JSON" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${LOG_PATH}/app.log</File>
<FileNamePattern>${LOG_PATH}/app.%d{yyyy-MM-dd}.%i.log.gz
</FileNamePattern>
...{code}
{code:java}
public class LoggerStartupListener extends ContextAwareBase implements
LoggerContextListener, LifeCycle {
private static final String LOG_PATH = "LOG_PATH";
@Override
public void start() {
getContext().putProperty(LOG_PATH, Paths.get(OSUtils.getBasePath(),
"logs").toString());
}
}{code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)