Java Code Examples for ch.qos.logback.classic.LoggerContext#putObject()
The following examples show how to use
ch.qos.logback.classic.LoggerContext#putObject() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultLogbackReInitializer.java From sofa-common-tools with Apache License 2.0 | 4 votes |
private void markAsReInitialized(LoggerContext loggerContext) { loggerContext.putObject(DefaultLogbackReInitializer.class.getCanonicalName(), new Object()); }
Example 2
Source File: LogbackLoggingSystem.java From super-cloudops with Apache License 2.0 | 4 votes |
private void markAsInitialized(LoggerContext loggerContext) { loggerContext.putObject(LoggingSystem.class.getName(), new Object()); }
Example 3
Source File: Application.java From ameba with MIT License | 4 votes |
/** * 设置日志器 */ private void configureLogger(Properties properties) { //set logback config file URL loggerConfigFile = getResource("conf/logback_" + getMode().name().toLowerCase() + ".groovy"); LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); context.reset(); context.putObject("properties", properties); if (loggerConfigFile != null) { GafferUtil.runGafferConfiguratorOn(context, this, loggerConfigFile); } URL userLoggerConfigFile = getResource(StringUtils.defaultIfBlank( properties.getProperty("logger.config.file"), "conf/" + DEFAULT_LOGBACK_CONF)); if (userLoggerConfigFile != null) { GafferUtil.runGafferConfiguratorOn(context, this, userLoggerConfigFile); } if (ids != null && ids.length > 0) { String confDir = "conf/log/"; String[] logConf = DEFAULT_LOGBACK_CONF.split("\\."); String logConfPrefix = logConf[0]; String logConfSuffix = "." + logConf[1]; for (String id : ids) { URL configFile = getResource(confDir + logConfPrefix + "_" + id + logConfSuffix); if (configFile != null) GafferUtil.runGafferConfiguratorOn(context, this, configFile); } } //java.util.logging.Logger proxy java.util.logging.Logger rootLogger = LogManager.getLogManager().getLogger(""); Handler[] handlers = rootLogger.getHandlers(); for (Handler handler : handlers) { rootLogger.removeHandler(handler); } SLF4JBridgeHandler.install(); rootLogger.setLevel(Level.ALL); String appPackage = properties.getProperty("app.package"); if (StringUtils.isBlank(appPackage)) { logger.warn(Messages.get("warn.app.package.not.config")); } }