Mercurial Hosting > luan
diff src/goodjava/logging/LoggerFactory.java @ 1448:6fc083e1d08c
start logger
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 23 Feb 2020 18:14:32 -0700 |
parents | 27efb1fcbcb5 |
children | 219f2b937f2b |
line wrap: on
line diff
--- a/src/goodjava/logging/LoggerFactory.java Tue Feb 18 14:54:35 2020 -0700 +++ b/src/goodjava/logging/LoggerFactory.java Sun Feb 23 18:14:32 2020 -0700 @@ -1,17 +1,26 @@ package goodjava.logging; -public abstract class LoggerFactory { - public static LoggerFactory implementation = new Log4jFactory(); - - protected abstract Logger getLoggerImpl(Class cls); - protected abstract Logger getLoggerImpl(String name); - - public static Logger getLogger(Class cls) { - return implementation.getLoggerImpl(cls); +public final class LoggerFactory { + public static final ILoggerFactory implementation; + static { + String s = System.getProperty("goodjava.logger","goodjava.logging.Log4jFactory"); + try { + implementation = (ILoggerFactory)Class.forName(s).newInstance(); + } catch(ClassNotFoundException e) { + throw new RuntimeException(e); + } catch(InstantiationException e) { + throw new RuntimeException(e); + } catch(IllegalAccessException e) { + throw new RuntimeException(e); + } } public static Logger getLogger(String name) { - return implementation.getLoggerImpl(name); + return implementation.getLogger(name); + } + + public static Logger getLogger(Class cls) { + return getLogger(cls.getName()); } }