1
0
mirror of https://github.com/moparisthebest/davmail synced 2025-01-10 05:08:08 -05:00

From coverity: synchronize FileAppender creation

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@2262 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2014-03-17 23:38:57 +00:00
parent db626f8956
commit 93515d8ddb

View File

@ -238,7 +238,6 @@ public final class Settings {
public static void updateLoggingConfig() { public static void updateLoggingConfig() {
String logFilePath = getLogFilePath(); String logFilePath = getLogFilePath();
Logger rootLogger = Logger.getRootLogger();
try { try {
if (logFilePath != null && logFilePath.length() > 0) { if (logFilePath != null && logFilePath.length() > 0) {
File logFile = new File(logFilePath); File logFile = new File(logFilePath);
@ -253,8 +252,9 @@ public final class Settings {
} else { } else {
logFilePath = "davmail.log"; logFilePath = "davmail.log";
} }
synchronized (Logger.getRootLogger()) {
// Build file appender // Build file appender
FileAppender fileAppender = (FileAppender) rootLogger.getAppender("FileAppender"); FileAppender fileAppender = (FileAppender) Logger.getRootLogger().getAppender("FileAppender");
if (fileAppender == null) { if (fileAppender == null) {
String logFileSize = Settings.getProperty("davmail.logFileSize"); String logFileSize = Settings.getProperty("davmail.logFileSize");
if (logFileSize == null || logFileSize.length() == 0) { if (logFileSize == null || logFileSize.length() == 0) {
@ -273,11 +273,12 @@ public final class Settings {
fileAppender.setLayout(new PatternLayout("%d{ISO8601} %-5p [%t] %c %x - %m%n")); fileAppender.setLayout(new PatternLayout("%d{ISO8601} %-5p [%t] %c %x - %m%n"));
} }
fileAppender.setFile(logFilePath, true, false, 8192); fileAppender.setFile(logFilePath, true, false, 8192);
rootLogger.addAppender(fileAppender); Logger.getRootLogger().addAppender(fileAppender);
}
// disable ConsoleAppender in gui mode // disable ConsoleAppender in gui mode
if (!Settings.getBooleanProperty("davmail.server")) { if (!Settings.getBooleanProperty("davmail.server")) {
ConsoleAppender consoleAppender = (ConsoleAppender) rootLogger.getAppender("ConsoleAppender"); ConsoleAppender consoleAppender = (ConsoleAppender) Logger.getRootLogger().getAppender("ConsoleAppender");
if (consoleAppender != null) { if (consoleAppender != null) {
consoleAppender.setThreshold(Level.OFF); consoleAppender.setThreshold(Level.OFF);
} }