forked from Qortal/qortal
Updated log4j to 2.17.1
This involves modifying the log4j2.properties file on node startup to fix an incompatibility with ${dirname:-}. Thanks to AlphaX Projects for tracking down this incompatibility.
This commit is contained in:
parent
5157ccf7c0
commit
b1c1634950
@ -61,7 +61,7 @@ appender.rolling.type = RollingFile
|
||||
appender.rolling.name = FILE
|
||||
appender.rolling.layout.type = PatternLayout
|
||||
appender.rolling.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
|
||||
appender.rolling.filePattern = ${dirname:-}${filename}.%i
|
||||
appender.rolling.filePattern = ./${filename}.%i
|
||||
appender.rolling.policy.type = SizeBasedTriggeringPolicy
|
||||
appender.rolling.policy.size = 4MB
|
||||
# Set the immediate flush to true (default)
|
||||
|
2
pom.xml
2
pom.xml
@ -23,7 +23,7 @@
|
||||
<hsqldb.version>2.5.1</hsqldb.version>
|
||||
<jersey.version>2.29.1</jersey.version>
|
||||
<jetty.version>9.4.29.v20200521</jetty.version>
|
||||
<log4j.version>2.12.1</log4j.version>
|
||||
<log4j.version>2.17.1</log4j.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<slf4j.version>1.7.12</slf4j.version>
|
||||
<swagger-api.version>2.0.9</swagger-api.version>
|
||||
|
@ -366,6 +366,8 @@ public class Controller extends Thread {
|
||||
// Entry point
|
||||
|
||||
public static void main(String[] args) {
|
||||
LoggingUtils.fixLegacyLog4j2Properties();
|
||||
|
||||
LOGGER.info("Starting up...");
|
||||
|
||||
// Potential GUI startup with splash screen, etc.
|
||||
|
31
src/main/java/org/qortal/utils/LoggingUtils.java
Normal file
31
src/main/java/org/qortal/utils/LoggingUtils.java
Normal file
@ -0,0 +1,31 @@
|
||||
package org.qortal.utils;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public class LoggingUtils {
|
||||
|
||||
public static void fixLegacyLog4j2Properties() {
|
||||
Path log4j2PropertiesPath = Paths.get("log4j2.properties");
|
||||
if (Files.exists(log4j2PropertiesPath)) {
|
||||
try {
|
||||
String content = FileUtils.readFileToString(log4j2PropertiesPath.toFile(), "UTF-8");
|
||||
if (content.contains("${dirname:-}")) {
|
||||
content = content.replace("${dirname:-}", "./");
|
||||
FileUtils.writeStringToFile(log4j2PropertiesPath.toFile(), content, "UTF-8");
|
||||
|
||||
// Force reload the log4j2.properties file
|
||||
((org.apache.logging.log4j.core.LoggerContext) LogManager.getContext(false)).reconfigure();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// Not much we can do here
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user