Ghidra is a software reverse engineering (SRE) framework
GP-6532: Fixed issue with script log redirect caused by the last log4j upgrade
Ryan Kurtz527b392c9540
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/script/ScriptMessage.java b/Ghidra/Features/Base/src/main/java/ghidra/app/script/ScriptMessage.javaindex f2539b6b3d..d54be81da1 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/script/ScriptMessage.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/script/ScriptMessage.java@@ -16,6 +16,7 @@package ghidra.app.script;import org.apache.logging.log4j.message.Message;+import org.apache.logging.log4j.message.StringFormattedMessage;/*** A simple {@link Message} implementation that allows us to use the filtering capability@@ -23,14 +24,22 @@ import org.apache.logging.log4j.message.Message;* message out. Our formatted message is the original message given to us. We use the* unformatted message, in conjunction with a regex filter to allow for filtering such that* the script log file only has script messages.- *- * <P>See log4j-appender-rolling-file-scripts.xml+ * <p>+ * See log4j-appender-rolling-file-scripts.xml+ * <p>+ * NOTE: {@link Message#getFormat()} was deprecated in log4j 2.24.0, and the behavior of+ * {@code useRawMsg} changed to only work with certain classes that implement the {@link Message}+ * interface, such as {@link StringFormattedMessage}. Implementing our own {@link Message}+ * resulted in {@code useRawMsg} not calling {@link #getFormat()}. See+ * <a href="https://github.com/apache/logging-log4j2/pull/2773">logging-log4j2/pull/2773</a> for+ * more info.*/-public class ScriptMessage implements Message {+public class ScriptMessage extends StringFormattedMessage {private String message;public ScriptMessage(String message) {+ super(message);this.message = message;}diff --git a/Ghidra/Framework/Generic/src/main/resources/log4j-appender-rolling-file-scripts.xml b/Ghidra/Framework/Generic/src/main/resources/log4j-appender-rolling-file-scripts.xmlindex e052b6ce35..0660de440a 100644--- a/Ghidra/Framework/Generic/src/main/resources/log4j-appender-rolling-file-scripts.xml+++ b/Ghidra/Framework/Generic/src/main/resources/log4j-appender-rolling-file-scripts.xml@@ -5,8 +5,8 @@Log4j appender that writes messages to a file.We filter the messages for this file by using the 'GhidraScript' text. This text is added- to the 'unformatted message' by using the log4j's Message class. We then emit the- original message when writing to the file.+ to the 'unformatted message' by using our ScriptMessage class, which extends log4j's+ StringFormattedMessage class. We then emit the original message when writing to the file.--><RollingFile