本文整理匯總了Java中org.slf4j.impl.StaticLoggerBinder.getSingleton方法的典型用法代碼示例。如果您正苦於以下問題:Java StaticLoggerBinder.getSingleton方法的具體用法?Java StaticLoggerBinder.getSingleton怎麽用?Java StaticLoggerBinder.getSingleton使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.slf4j.impl.StaticLoggerBinder
的用法示例。
在下文中一共展示了StaticLoggerBinder.getSingleton方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initializeLogging
import org.slf4j.impl.StaticLoggerBinder; //導入方法依賴的package包/類
private void initializeLogging() {
String graviteeHome = System.getProperty("gravitee.home");
String logbackConfiguration = graviteeHome + File.separator + "config" + File.separator + "logback.xml";
File logbackConfigurationfile = new File(logbackConfiguration);
// If logback configuration available, load it, else, load default logback configuration
if (logbackConfigurationfile.exists()) {
System.setProperty("logback.configurationFile", logbackConfigurationfile.getAbsolutePath());
StaticLoggerBinder loggerBinder = StaticLoggerBinder.getSingleton();
LoggerContext loggerContext = (LoggerContext) loggerBinder.getLoggerFactory();
loggerContext.reset();
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(loggerContext);
try {
configurator.doConfigure(logbackConfigurationfile);
} catch( JoranException e ) {
e.printStackTrace();
}
// Internal status data is printed in case of warnings or errors.
StatusPrinter.printInCaseOfErrorsOrWarnings(loggerContext);
}
}
示例2: initializeLogging
import org.slf4j.impl.StaticLoggerBinder; //導入方法依賴的package包/類
private void initializeLogging() {
String graviteeHome = System.getProperty("gravitee.home");
String logbackConfiguration = graviteeHome + File.separator + "config" + File.separator + "logback.xml";
File logbackConfigurationfile = new File(logbackConfiguration);
// If logback configuration available, load it, else, load default logback configuration
if (logbackConfigurationfile.exists()) {
System.setProperty("logback.configurationFile", logbackConfigurationfile.getAbsolutePath());
StaticLoggerBinder loggerBinder = StaticLoggerBinder.getSingleton();
LoggerContext loggerContext = (LoggerContext) loggerBinder.getLoggerFactory();
loggerContext.reset();
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(loggerContext);
try {
configurator.doConfigure(logbackConfigurationfile);
} catch( JoranException e ) {
LoggerFactory.getLogger(Container.class).error("An error occurs while initializing logging system", e);
}
// Internal status data is printed in case of warnings or errors.
StatusPrinter.printInCaseOfErrorsOrWarnings(loggerContext);
}
}
示例3: bind
import org.slf4j.impl.StaticLoggerBinder; //導入方法依賴的package包/類
private static final void bind() {
String msg;
try {
Set e = findPossibleStaticLoggerBinderPathSet();
reportMultipleBindingAmbiguity(e);
StaticLoggerBinder.getSingleton();
INITIALIZATION_STATE = 3;
reportActualBinding(e);
fixSubstitutedLoggers();
} catch (NoClassDefFoundError var2) {
msg = var2.getMessage();
if(!messageContainsOrgSlf4jImplStaticLoggerBinder(msg)) {
failedBinding(var2);
throw var2;
}
INITIALIZATION_STATE = 4;
Util.report("Failed to load class \"org.slf4j.impl.StaticLoggerBinder\".");
Util.report("Defaulting to no-operation (NOP) logger implementation");
Util.report("See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.");
} catch (NoSuchMethodError var3) {
msg = var3.getMessage();
if(msg != null && msg.contains("org.slf4j.impl.StaticLoggerBinder.getSingleton()")) {
INITIALIZATION_STATE = 2;
Util.report("slf4j-api 1.6.x (or later) is incompatible with this binding.");
Util.report("Your binding is version 1.5.5 or earlier.");
Util.report("Upgrade your binding to version 1.6.x.");
}
throw var3;
} catch (Exception var4) {
failedBinding(var4);
throw new IllegalStateException("Unexpected initialization failure", var4);
}
}
示例4: setup
import org.slf4j.impl.StaticLoggerBinder; //導入方法依賴的package包/類
@Before
public void setup() {
this.environment = new MockEnvironment();
this.initializationContext = new LoggingInitializationContext(this.environment);
this.configurator = new SpringBootJoranConfigurator(this.initializationContext);
StaticLoggerBinder binder = StaticLoggerBinder.getSingleton();
this.context = (LoggerContext) binder.getLoggerFactory();
this.logger = this.context.getLogger(getClass());
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:10,代碼來源:SpringBootJoranConfiguratorTests.java
示例5: execute
import org.slf4j.impl.StaticLoggerBinder; //導入方法依賴的package包/類
@Override
public final void execute() throws MojoExecutionException, MojoFailureException {
StaticLoggerBinder staticLoggerBinder = StaticLoggerBinder.getSingleton();
staticLoggerBinder.setLog(getLog());
try {
doExecute();
} finally {
staticLoggerBinder.revokeLog();
}
}
示例6: getLogger
import org.slf4j.impl.StaticLoggerBinder; //導入方法依賴的package包/類
@SuppressWarnings({ "rawtypes" })
public static Logger getLogger(Class clazz, String contextName) {
Logger logger = null;
try {
//check for logback
Class cs = Class.forName("ch.qos.logback.classic.selector.ContextSelector");
//trigger an exception if the class doesn't actually exist
cs.getDeclaredMethods();
// get the class for static binding
cs = Class.forName("org.slf4j.impl.StaticLoggerBinder");
// get its declared methods
Method[] methods = cs.getDeclaredMethods();
for (Method method : methods) {
//ensure method exists
if (method.getName().equals("getContextSelector")) {
//System.out.println("Logger context selector method found");
//get the context selector
StaticLoggerBinder binder = StaticLoggerBinder.getSingleton();
Method m1 = binder.getClass().getMethod("getContextSelector", (Class[]) null);
ContextSelector selector = (ContextSelector) m1.invoke(binder, (Object[]) null);
//get the context for the given context name or default if null
LoggerContext ctx = null;
if (contextName != null && contextName.length() > 0) {
ctx = selector.getLoggerContext(contextName);
}
// and if we get here, fall back to the default context
if (ctx == null) {
ctx = selector.getLoggerContext();
}
//debug
//StatusPrinter.print(ctx);
//get the logger from the context or default context
logger = ((ctx != null) ? ctx.getLogger(clazz) : selector.getDefaultLoggerContext().getLogger(clazz));
break;
}
}
} catch (Exception e) {
//no logback, use whatever logger is in-place
System.err.printf("Exception %s", e.getMessage());
}
if (logger == null) {
//no logback, use whatever logger is in-place
logger = LoggerFactory.getLogger(clazz);
}
return logger;
}