本文整理了Java中org.apache.logging.log4j.core.config.Configuration.removeLogger()
方法的一些代码示例,展示了Configuration.removeLogger()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.removeLogger()
方法的具体详情如下:
包路径:org.apache.logging.log4j.core.config.Configuration
类名称:Configuration
方法名:removeLogger
暂无
代码示例来源:origin: org.infinispan/infinispan-commons-test
public void uninstall() {
LoggerContext loggerContext = (LoggerContext) LogManager.getContext(false);
loggerContext.getConfiguration().removeLogger(category);
loggerContext.updateLoggers();
}
代码示例来源:origin: apache/asterixdb
public static void main(String[] args) {
try {
final String nodeId = ConfigUtils.getOptionValue(args, NCConfig.Option.NODE_ID);
final ConfigManager configManager = new ConfigManager(args);
INCApplication application = getApplication(args);
application.registerConfig(configManager);
NCConfig ncConfig = new NCConfig(nodeId, configManager);
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configuration cfg = ctx.getConfiguration();
NCLogConfigurationFactory logCfgFactory = new NCLogConfigurationFactory(ncConfig);
ConfigurationFactory.setConfigurationFactory(logCfgFactory);
configManager.processConfig();
cfg.removeLogger("Console");
ctx.start(logCfgFactory.getConfiguration(ctx, ConfigurationSource.NULL_SOURCE));
final NodeControllerService ncService = new NodeControllerService(ncConfig, application);
ncService.start();
while (true) {
Thread.sleep(10000);
}
} catch (CmdLineException e) {
LOGGER.log(Level.DEBUG, "Exception parsing command line: " + Arrays.toString(args), e);
System.exit(2);
} catch (Exception e) {
LOGGER.error("Exiting NCDriver due to exception", e);
System.exit(1);
}
}
代码示例来源:origin: apache/asterixdb
public static void main(String[] args) throws Exception {
try {
final ConfigManager configManager = new ConfigManager(args);
ICCApplication application = getApplication(args);
application.registerConfig(configManager);
CCConfig ccConfig = new CCConfig(configManager);
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configuration cfg = ctx.getConfiguration();
CCLogConfigurationFactory logCfgFactory = new CCLogConfigurationFactory(ccConfig);
ConfigurationFactory.setConfigurationFactory(logCfgFactory);
cfg.removeLogger("Console");
configManager.processConfig();
ctx.start(logCfgFactory.getConfiguration(ctx, ConfigurationSource.NULL_SOURCE));
ClusterControllerService ccService = new ClusterControllerService(ccConfig, application);
ccService.start();
while (true) {
Thread.sleep(100000);
}
} catch (CmdLineException e) {
LOGGER.log(Level.DEBUG, "Exception parsing command line: " + Arrays.toString(args), e);
System.exit(2);
} catch (Exception e) {
LOGGER.log(Level.ERROR, "Exiting CCDriver due to exception", e);
System.exit(1);
}
}
代码示例来源:origin: fbacchella/LogHub
public static void setAppender() {
LoggerContext ctx = (LoggerContext) LogManager.getContext(true);
org.apache.logging.log4j.core.config.Configuration config = ctx.getConfiguration();
// If the event logger already exists, do nothing
if (config.getLoggers().containsKey(LOGGERNAME)) {
return;
}
Layout<String> layout = PatternLayout.newBuilder().withPattern("%msg%n").withConfiguration(config).build();
Appender jsonappender = ConsoleAppender.newBuilder()
.withName(APPENDERNAME)
.setTarget(ConsoleAppender.Target.SYSTEM_ERR)
.withLayout(layout)
.setConfiguration(config)
.build();
jsonappender.start();
config.addAppender(jsonappender);
AppenderRef ref = AppenderRef.createAppenderRef(APPENDERNAME, null, null);
LoggerConfig loggerConfig = LoggerConfig.createLogger(false, LOGLEVEL, LOGGERNAME, "false", new AppenderRef[] {ref}, new Property[]{}, config, (Filter) null);
loggerConfig.addAppender(jsonappender, null, null);
config.removeLogger(LOGGERNAME);
config.addLogger(LOGGERNAME, loggerConfig);
ctx.updateLoggers();
}
}
内容来源于网络,如有侵权,请联系作者删除!