Reactivate stack traces in OSGi logging.
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / internal / kernel / NodeLogger.java
index 045229ce1fc81eadfe7fb8bade2e317c4f99270f..0c5899795a73fb4d29638a337dee8e00a3ec4c7e 100644 (file)
@@ -16,6 +16,7 @@
 package org.argeo.cms.internal.kernel;
 
 import java.io.IOException;
+import java.net.URI;
 import java.nio.file.FileSystems;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -51,6 +52,7 @@ import org.argeo.node.ArgeoLogListener;
 import org.argeo.node.ArgeoLogger;
 import org.argeo.node.NodeConstants;
 import org.argeo.osgi.useradmin.UserAdminConf;
+import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.cm.ConfigurationAdmin;
@@ -98,7 +100,6 @@ class NodeLogger implements ArgeoLogger, LogListener {
                }
        };
 
-       @SuppressWarnings("unchecked")
        public NodeLogger(LogReaderService lrs) {
                Enumeration<LogEntry> logEntries = lrs.getLog();
                while (logEntries.hasMoreElements())
@@ -115,7 +116,11 @@ class NodeLogger implements ArgeoLogger, LogListener {
                                        log4jConfiguration = log4jConfiguration.substring("file:".length());
                        }
                        try {
-                               Path log4jconfigPath = Paths.get(log4jConfiguration);
+                               Path log4jconfigPath;
+                               if (log4jConfiguration.startsWith("file:"))
+                                       log4jconfigPath = Paths.get(new URI(log4jConfiguration));
+                               else
+                                       log4jconfigPath = Paths.get(log4jConfiguration);
                                Thread log4jConfWatcher = new Log4jConfWatcherThread(log4jconfigPath);
                                log4jConfWatcher.start();
                        } catch (Exception e) {
@@ -166,6 +171,7 @@ class NodeLogger implements ArgeoLogger, LogListener {
        //
        // OSGi LOGGER
        //
+       @SuppressWarnings("deprecation")
        @Override
        public void logged(LogEntry status) {
                Log pluginLog = LogFactory.getLog(status.getBundle().getSymbolicName());
@@ -186,6 +192,10 @@ class NodeLogger implements ArgeoLogger, LogListener {
        private String msg(LogEntry status) {
                StringBuilder sb = new StringBuilder();
                sb.append(status.getMessage());
+               Bundle bundle = status.getBundle();
+               if (bundle != null) {
+                       sb.append(" '" + bundle.getSymbolicName() + "'");
+               }
                ServiceReference<?> sr = status.getServiceReference();
                if (sr != null) {
                        sb.append(' ');