本文整理匯總了Java中org.slf4j.ILoggerFactory.getLogger方法的典型用法代碼示例。如果您正苦於以下問題:Java ILoggerFactory.getLogger方法的具體用法?Java ILoggerFactory.getLogger怎麽用?Java ILoggerFactory.getLogger使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.slf4j.ILoggerFactory
的用法示例。
在下文中一共展示了ILoggerFactory.getLogger方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getRealLoggerInstance
import org.slf4j.ILoggerFactory; //導入方法依賴的package包/類
/**
* Find the actual {@code Logger} instance that is available on the classpath.
* This is usually the logger adapter that is provided by the real logging framework,
* such as log4j, etc. The method will scan the runtime to find logger factories that
* are of type {@link org.slf4j.ILoggerFactory}. It will remove itself from this list
* first and then attempts to locate the next best factory from which real logger instances
* can be created.
* @param name requested logger name
* @return the logger instance created by the logger factory available on the classpath during runtime, or null.
*/
private Logger getRealLoggerInstance(final String name) {
try {
final ILoggerFactory factInstance = getLoggerFactoryBeInstantiated(this.realLoggerFactoryClass);
if (factInstance == null) {
throw new RuntimeException("ILoggerFactory cannot be created from "
+ this.realLoggerFactoryClass.getName());
}
return factInstance.getLogger(name);
} catch (final Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
}
示例2: setRootLogLevel
import org.slf4j.ILoggerFactory; //導入方法依賴的package包/類
public void setRootLogLevel() {
ILoggerFactory factory = StaticLoggerBinder.getSingleton().getLoggerFactory();
Logger logger = factory.getLogger(Logger.ROOT_LOGGER_NAME);
((ch.qos.logback.classic.Logger) logger).setLevel(Level.INFO);
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:6,代碼來源:LogbackInitializer.java
示例3: Example
import org.slf4j.ILoggerFactory; //導入方法依賴的package包/類
public Example(ILoggerFactory lf) {
this.logger = lf.getLogger(Example.class.getName());
}
示例4: Example
import org.slf4j.ILoggerFactory; //導入方法依賴的package包/類
Example(ILoggerFactory lf) {
this.logger = lf.getLogger(this.getClass().getName());
internalDetail = new InternalSubcomponent(lf);
}
示例5: InternalSubcomponent
import org.slf4j.ILoggerFactory; //導入方法依賴的package包/類
InternalSubcomponent(ILoggerFactory lf) {
this.logger = lf.getLogger(this.getClass().getName());
}
示例6: start
import org.slf4j.ILoggerFactory; //導入方法依賴的package包/類
@Override
public void start(BundleContext context) {
// Lets trigger the resolution of the slf4j logger factory
ILoggerFactory f = LoggerFactory.getILoggerFactory();
// Now retrieve a logger for the bridge
log = f
.getLogger("org.opendaylight.controller.logging.bridge.OSGI2SLF4J");
if (this.log != null) {
this.listener = new LogListenerImpl(log);
ServiceReference service = null;
service = context.getServiceReference(LogReaderService.class
.getName());
if (service != null) {
LogReaderService reader = (LogReaderService) context
.getService(service);
if (reader == null) {
this.log.error("Cannot register the LogListener because "
+ "cannot retrieve LogReaderService");
}
reader.addLogListener(this.listener);
// Now lets walk all the exiting messages
Enumeration<LogEntry> entries = reader.getLog();
if (entries != null) {
while (entries.hasMoreElements()) {
LogEntry entry = (LogEntry) entries.nextElement();
this.listener.logged(entry);
}
}
/*
* Install the default exception handler so that the uncaught
* exceptions are handled by our customized handler. This new
* handler will display the exceptions to OSGI console as well
* as log to file.
*/
Thread.setDefaultUncaughtExceptionHandler(new org.opendaylight.
controller.logging.bridge.internal.UncaughtExceptionHandler());
/*
* Install the Shutdown handler. This will intercept SIGTERM signal and
* close the system bundle. This allows for a graceful closing of OSGI
* framework.
*/
Runtime.getRuntime().addShutdownHook(new shutdownHandler(context));
} else {
this.log.error("Cannot register the LogListener because "
+ "cannot retrieve LogReaderService");
}
} else {
System.err
.println("Could not initialize the logging bridge subsytem");
}
}
示例7: getRealLoggerInstance
import org.slf4j.ILoggerFactory; //導入方法依賴的package包/類
/**
* Find the actual <code>Logger</code> instance that is available on the classpath.
* This is usually the logger adapter that is provided by the real logging framework,
* such as log4j, etc. The method will scan the runtime to find logger factories that
* are of type {@link org.slf4j.ILoggerFactory}. It will remove itself from this list
* first and then attempts to locate the next best factory from which real logger instances
* can be created.
* @param name requested logger name
* @return the logger instance created by the logger factory available on the classpath during runtime, or null.
*/
private Logger getRealLoggerInstance(final String name) {
try {
final ILoggerFactory factInstance = this.realLoggerFactoryClass.newInstance();
return factInstance.getLogger(name);
} catch (final Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
}