JAL-4109 examine -Djalview.loglevel on startup to decide what the default log level...
authorJim Procter <j.procter@dundee.ac.uk>
Fri, 16 Dec 2022 16:45:18 +0000 (16:45 +0000)
committerJim Procter <j.procter@dundee.ac.uk>
Fri, 16 Dec 2022 16:45:18 +0000 (16:45 +0000)
src/jalview/bin/Console.java
test/jalview/io/testProps.jvprops

index 3e09d07..53ff753 100644 (file)
@@ -30,7 +30,7 @@ import jalview.util.Platform;
 public class Console
 {
 
-  public static JLoggerLog4j log;
+  public static JLoggerLog4j log=null;
 
   public static void debug(String message, Throwable t)
   {
@@ -220,7 +220,14 @@ public class Console
     }
     try
     {
-      JLogger.LogLevel cachedLevel = getCachedLogLevel();
+      JLogger.LogLevel cachedLevel=null;
+      if (System.getProperty("jalview.loglevel")!=null)
+      {
+        cachedLevel = JLogger.LogLevel.valueOf(System.getProperty("jalview.loglevel"));
+      }
+      if (cachedLevel==null) {
+        cachedLevel = getCachedLogLevel();
+      }
       if (!Platform.isJS())
       {
         Log4j.init(cachedLevel);
@@ -232,6 +239,7 @@ public class Console
 
       // The main application logger
       log = JLoggerLog4j.getLogger(Cache.JALVIEW_LOGGER_NAME, cachedLevel);
+      log.info("Logging initialised at level: "+cachedLevel);
     } catch (NoClassDefFoundError e)
     {
       System.err.println("Could not initialise the logger framework");
index 94bc5d9..bca2958 100644 (file)
@@ -1,6 +1,7 @@
 #---JalviewX Properties File---
 #Fri Apr 25 09:54:25 BST 2014
-#
+# Uncomment to enable debug logging
+# logs.Jalview.level=DEBUG
 BACKUPFILES_ENABLED=true
 BACKUPFILES_PRESET=0
 BACKUPFILES_SAVED=_BACKUPFILESTESTTMP%n\t6\tfalse\tfalse\t2\tfalse