view src/goodjava/logging/LoggerFactory.java @ 1452:c15444f4da05

Slf4jFactory
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 01 Mar 2020 16:05:26 -0700
parents 6fc083e1d08c
children 219f2b937f2b
line wrap: on
line source

package goodjava.logging;


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.getLogger(name);
	}

	public static Logger getLogger(Class cls) {
		return getLogger(cls.getName());
	}
}