Package cn.sliew.milky.log
Class LoggerFactory
- java.lang.Object
-
- cn.sliew.milky.log.LoggerFactory
-
- Direct Known Subclasses:
Log4J2LoggerFactory,NoLoggerFactory,Slf4jLoggerFactory,StdOutLoggerFactory
public abstract class LoggerFactory extends Object
Creates anLoggeror changes the default factory implementation. This factory allows you to choose what logging framework Netty should use. The default factory isSlf4jLoggerFactory. If SLF4J is not available,Log4J2LoggerFactoryis used. You can change it to your preferred logging framework before other Netty classes are loaded:
Please note that the new default factory is effective only for the classes which were loaded after the default factory is changed. Therefore,LoggerFactory.setDefaultFactory(Log4J2LoggerFactory.INSTANCE);setDefaultFactory(LoggerFactory)should be called as early as possible and shouldn't be called more than once.
-
-
Constructor Summary
Constructors Constructor Description LoggerFactory()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static LoggerFactorygetDefaultFactory()Returns the default factory.static LoggergetLogger(Class<?> clazz)Creates a new logger instance with the name of the specified class.static LoggergetLogger(String name)Creates a new logger instance with the specified name.protected abstract LoggernewInstance(String name)Creates a new logger instance with the specified name.static voidsetDefaultFactory(LoggerFactory defaultFactory)Changes the default factory.
-
-
-
Method Detail
-
getDefaultFactory
public static LoggerFactory getDefaultFactory()
Returns the default factory. The initial default factory isSlf4jLoggerFactory.
-
setDefaultFactory
public static void setDefaultFactory(LoggerFactory defaultFactory)
Changes the default factory.
-
getLogger
public static Logger getLogger(Class<?> clazz)
Creates a new logger instance with the name of the specified class.
-
getLogger
public static Logger getLogger(String name)
Creates a new logger instance with the specified name.
-
-