Skip to content
Permalink
Browse files

0004324: Upgrade to log4j2

  • Loading branch information
erilong committed Mar 24, 2020
1 parent 8fbe4a5 commit fa7db0ec2eb1104e43678f3a99c571c210ba49cf
@@ -251,6 +251,7 @@ protected void configureLogging(CommandLine line) throws MalformedURLException {
Appender appender = LogSummaryAppenderUtils.getAppender("ROLLING");
if (appender instanceof RollingFileAppender) {
RollingFileAppender fa = (RollingFileAppender) appender;
String fileName = fa.getFileName();

if (line.hasOption(OPTION_PROPERTIES_FILE)) {
File file = new File(line.getOptionValue(OPTION_PROPERTIES_FILE));
@@ -259,17 +260,18 @@ protected void configureLogging(CommandLine line) throws MalformedURLException {
if (index > 0) {
name = name.substring(0, index);
}
fileName = fileName.replace("symmetric.log", name + ".log");
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configuration config = ctx.getConfiguration();
RollingFileAppender rolling = RollingFileAppender.newBuilder().setConfiguration(config).setName("ROLLING")
.withFileName(fa.getFileName().replace("symmetric.log", name + ".log"))
.withFileName(fileName)
.withFilePattern(fa.getFilePattern().replace("symmetric.log", name + ".log"))
.setLayout(fa.getLayout()).withPolicy(fa.getTriggeringPolicy())
.withStrategy(fa.getManager().getRolloverStrategy()).build();
LogSummaryAppenderUtils.removeAppender("ROLLING");
LogSummaryAppenderUtils.addAppender(rolling);
}
System.err.println(String.format("Log output will be written to %s", fa.getFileName()));
System.err.println(String.format("Log output will be written to %s", fileName));
}
}
}
@@ -5,7 +5,7 @@
<ThresholdFilter level="WARN" onMatch="ACCEPT" onMismatch="DENY" />
<PatternLayout pattern="[%X{engineName}] - %c{1} - %m%n" />
</Console>
<RollingFile name="ROLLING" fileName="${env:SYM_HOME:-.}/logs/symmetric.log" filePattern="${sys:log4j.sym.home}/logs/symmetric.log.%i">
<RollingFile name="ROLLING" fileName="${env:SYM_HOME:-.}/logs/symmetric.log" filePattern="${env:SYM_HOME:-.}/logs/symmetric.log.%i" createOnDemand="true">
<PatternLayout pattern="%d %p [%X{engineName}] [%c{1}] [%t] %m%n" />
<Policies>
<SizeBasedTriggeringPolicy size="20 MB" />
@@ -5,7 +5,7 @@
<ThresholdFilter level="WARN" onMatch="ACCEPT" onMismatch="DENY" />
<PatternLayout pattern="[%X{engineName}] - %c{1} - %m%n" />
</Console>
<RollingFile name="ROLLING" fileName="${env:SYM_HOME:-.}/logs/symmetric.log" filePattern="${sys:log4j.sym.home}/logs/symmetric.log.%i">
<RollingFile name="ROLLING" fileName="${env:SYM_HOME:-.}/logs/symmetric.log" filePattern="${env:SYM_HOME:-.}/logs/symmetric.log.%i" createOnDemand="true">
<PatternLayout pattern="%d %p [%X{engineName}] [%c{1}] [%t] %m%n" />
<Policies>
<SizeBasedTriggeringPolicy size="20 MB" />

This file was deleted.

0 comments on commit fa7db0e

Please sign in to comment.
You can’t perform that action at this time.