X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.init%2Fsrc%2Forg%2Fargeo%2Finit%2Flogging%2FThinLoggerFinder.java;h=9607c9478df78c3f5f259111a4ed7aab46ef4cee;hb=01b972e4abce933b3ce06bd18e933b08d3b35464;hp=7849309460933695f5b60a96d44f5e8cf2592c4c;hpb=b7d8618ce593bbeca7e311d32a4d98988e27f877;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.init/src/org/argeo/init/logging/ThinLoggerFinder.java b/org.argeo.init/src/org/argeo/init/logging/ThinLoggerFinder.java index 784930946..9607c9478 100644 --- a/org.argeo.init/src/org/argeo/init/logging/ThinLoggerFinder.java +++ b/org.argeo.init/src/org/argeo/init/logging/ThinLoggerFinder.java @@ -5,9 +5,11 @@ import java.lang.System.LoggerFinder; /** Factory for Java system logging. */ public class ThinLoggerFinder extends LoggerFinder { - private ThinLogging logging; + private static ThinLogging logging; public ThinLoggerFinder() { + if (logging != null) + throw new IllegalStateException("Only one logging can be initialised."); logging = new ThinLogging(); } @@ -16,4 +18,17 @@ public class ThinLoggerFinder extends LoggerFinder { return logging.getLogger(name, module); } + /** + * Falls back to java.util.logging if thin logging was not already initialised. + */ + public static void lazyInit() { + if (logging != null) + return; + logging = new ThinLogging(); + ThinJavaUtilLogging.init(); + } + + public static Logger getLogger(String name) { + return logging.getLogger(name, null); + } }