New settings method: return log file directory

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@687 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2009-09-02 09:42:11 +00:00
parent d9deaa53c1
commit e0ce94ab7e
1 changed files with 33 additions and 4 deletions

View File

@ -129,15 +129,44 @@ public class Settings {
}
/**
* Update Log4J config from settings.
* Return DavMail log file path
* @return full log file path
*/
protected static void updateLoggingConfig() {
String logFilePath = Settings.getProperty("davmail.logFilePath");
public static String getLogFilePath() {
String logFilePath = Settings.getProperty("davmail.logFilePath");
// use default log file path on Mac OS X
if ((logFilePath == null || logFilePath.length() == 0)
if ((logFilePath == null || logFilePath.length() == 0)
&& System.getProperty("os.name").toLowerCase().startsWith("mac os x")) {
logFilePath = System.getProperty("user.home") + "/Library/Logs/DavMail/davmail.log";
}
return logFilePath;
}
/**
* Return DavMail log file directory
* @return full log file directory
*/
public static String getLogFileDirectory() {
String logFilePath = getLogFilePath();
if (logFilePath == null || logFilePath.length() == 0) {
return "";
}
int lastSlashIndex = logFilePath.lastIndexOf('/');
if (lastSlashIndex == -1) {
lastSlashIndex = logFilePath.lastIndexOf('\\');
}
if (lastSlashIndex >= 0) {
return logFilePath.substring(0, lastSlashIndex);
} else {
return "";
}
}
/**
* Update Log4J config from settings.
*/
protected static void updateLoggingConfig() {
String logFilePath = getLogFilePath();
Logger rootLogger = Logger.getRootLogger();
try {