Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
Fixed issue that avoided changing logging path for log4j2
  • Loading branch information
odoodo authored Jan 10, 2024
1 parent f7ee3ed commit 475d8c7
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions lu/hrs/mirth/MetaAppenderLog4J2.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package lu.hrs.mirth;

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.util.HashMap;
Expand Down Expand Up @@ -340,8 +342,21 @@ private MetaAppenderLog4J2(String customLogPath, String customMaxFileSize, Integ
this.configLayout = (customLogPattern != null) ? customLogPattern : mainLogAppender.getLayout().toString();

try {
// files will be placed at the same location like mirth.log
this.configLogLocation = Paths.get(mainLogAppender.getFileName()).getParent().toFile().getAbsolutePath();
// if a custom log file location was set
if((customLogPath != null) && (customLogPath.length() > 0)) {
try {
// assure that the path actually exists
Files.createDirectories(Paths.get(customLogPath));

} catch (IOException e) {
// if path could not be created, use the one configured by the mirth log4j2 configuration
customLogPath = null;
}
}

// set the log file location
this.configLogLocation = (customLogPath == null) ? Paths.get(mainLogAppender.getFileName()).getParent().toFile().getAbsolutePath() : customLogPath;

} catch (Exception e) {
StringWriter sw = new StringWriter();
ExceptionUtils.printRootCauseStackTrace(e, new PrintWriter(sw));
Expand Down

0 comments on commit 475d8c7

Please sign in to comment.