aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/helper/Log.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-02-23 10:25:30 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2019-02-23 10:25:30 -0800
commitdb88a6d69e036c383b91817991e7e4be1fb8bd54 (patch)
tree09ae5439f931d2a164194f934c92dcfa1914a7df /src/org/traccar/helper/Log.java
parent6ca6c510843bf5fe0aa49aa00237dc077fdf1589 (diff)
downloadtrackermap-server-db88a6d69e036c383b91817991e7e4be1fb8bd54.tar.gz
trackermap-server-db88a6d69e036c383b91817991e7e4be1fb8bd54.tar.bz2
trackermap-server-db88a6d69e036c383b91817991e7e4be1fb8bd54.zip
Handle common crash
Diffstat (limited to 'src/org/traccar/helper/Log.java')
-rw-r--r--src/org/traccar/helper/Log.java18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/org/traccar/helper/Log.java b/src/org/traccar/helper/Log.java
index df0c9abc1..667f669fe 100644
--- a/src/org/traccar/helper/Log.java
+++ b/src/org/traccar/helper/Log.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2019 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@ import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
+import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -162,12 +163,17 @@ public final class Log {
}
public static void setupDefaultLogger() {
- File jarPath = new File(ClassLoader.getSystemClassLoader().getResource(".").getPath());
- File logsPath = new File(jarPath, "logs");
- if (!logsPath.exists() || !logsPath.isDirectory()) {
- logsPath = jarPath;
+ String path = null;
+ URL url = ClassLoader.getSystemClassLoader().getResource(".");
+ if (url != null) {
+ File jarPath = new File(url.getPath());
+ File logsPath = new File(jarPath, "logs");
+ if (!logsPath.exists() || !logsPath.isDirectory()) {
+ logsPath = jarPath;
+ }
+ path = new File(logsPath, "tracker-server.log").getPath();
}
- setupLogger(false, new File(logsPath, "tracker-server.log").getPath(), Level.WARNING.getName(), false, true);
+ setupLogger(path == null, path, Level.WARNING.getName(), false, true);
}
public static void setupLogger(Config config) {