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:
parent
d9deaa53c1
commit
e0ce94ab7e
|
@ -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() {
|
public static String getLogFilePath() {
|
||||||
String logFilePath = Settings.getProperty("davmail.logFilePath");
|
String logFilePath = Settings.getProperty("davmail.logFilePath");
|
||||||
// use default log file path on Mac OS X
|
// 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")) {
|
&& System.getProperty("os.name").toLowerCase().startsWith("mac os x")) {
|
||||||
logFilePath = System.getProperty("user.home") + "/Library/Logs/DavMail/davmail.log";
|
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();
|
Logger rootLogger = Logger.getRootLogger();
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue