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:
parent
db626f8956
commit
93515d8ddb
@ -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) {
|
||||||
@ -265,19 +265,20 @@ public final class Settings {
|
|||||||
fileAppender = new FileAppender();
|
fileAppender = new FileAppender();
|
||||||
} else {
|
} else {
|
||||||
fileAppender = new RollingFileAppender();
|
fileAppender = new RollingFileAppender();
|
||||||
((RollingFileAppender)fileAppender).setMaxBackupIndex(2);
|
((RollingFileAppender) fileAppender).setMaxBackupIndex(2);
|
||||||
((RollingFileAppender)fileAppender).setMaxFileSize(logFileSize);
|
((RollingFileAppender) fileAppender).setMaxFileSize(logFileSize);
|
||||||
}
|
}
|
||||||
fileAppender.setName("FileAppender");
|
fileAppender.setName("FileAppender");
|
||||||
fileAppender.setEncoding("UTF-8");
|
fileAppender.setEncoding("UTF-8");
|
||||||
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);
|
||||||
}
|
}
|
||||||
@ -488,9 +489,9 @@ public final class Settings {
|
|||||||
}
|
}
|
||||||
Properties result = new Properties();
|
Properties result = new Properties();
|
||||||
for (Map.Entry entry : SETTINGS.entrySet()) {
|
for (Map.Entry entry : SETTINGS.entrySet()) {
|
||||||
String key = (String)entry.getKey();
|
String key = (String) entry.getKey();
|
||||||
if (key.startsWith(keyStart)) {
|
if (key.startsWith(keyStart)) {
|
||||||
String value = (String)entry.getValue();
|
String value = (String) entry.getValue();
|
||||||
result.setProperty(key.substring(keyStart.length()), value);
|
result.setProperty(key.substring(keyStart.length()), value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user