本文整理汇总了Java中org.apache.logging.log4j.core.config.LoggerConfig.getProperties方法的典型用法代码示例。如果您正苦于以下问题:Java LoggerConfig.getProperties方法的具体用法?Java LoggerConfig.getProperties怎么用?Java LoggerConfig.getProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.logging.log4j.core.config.LoggerConfig
的用法示例。
在下文中一共展示了LoggerConfig.getProperties方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOrCreateLoggerConfig
import org.apache.logging.log4j.core.config.LoggerConfig; //导入方法依赖的package包/类
public static LoggerConfig getOrCreateLoggerConfig(String name) {
LoggerContext context = (LoggerContext) LogManager.getContext(false);
Configuration config = context.getConfiguration();
LoggerConfig logConfig = config.getLoggerConfig(name);
boolean update = false;
if (!logConfig.getName().equals(name)) {
List<AppenderRef> appenderRefs = logConfig.getAppenderRefs();
Map<Property, Boolean> properties = logConfig.getProperties();
Set<Property> props = properties == null ? null : properties.keySet();
logConfig = LoggerConfig.createLogger(String.valueOf(logConfig.isAdditive()),
logConfig.getLevel(), name, String.valueOf(logConfig.isIncludeLocation()),
appenderRefs == null ? null : appenderRefs.toArray(new AppenderRef[appenderRefs.size()]),
props == null ? null : props.toArray(new Property[props.size()]), config, null);
config.addLogger(name, logConfig);
update = true;
}
if (update) {
context.updateLoggers();
}
return logConfig;
}
示例2: main
import org.apache.logging.log4j.core.config.LoggerConfig; //导入方法依赖的package包/类
public static void main(String [] args){
try{
System.out.println(logger1.isDebugEnabled());
System.out.println(logger1.isErrorEnabled());
System.out.println(logger1.isInfoEnabled());
System.out.println(logger2.isDebugEnabled());
System.out.println(logger2.isErrorEnabled());
System.out.println(logger2.isInfoEnabled());
System.out.println(logger3.isDebugEnabled());
System.out.println(logger3.isErrorEnabled());
System.out.println(logger3.isInfoEnabled());
System.out.println(logger4.isDebugEnabled());
System.out.println(logger4.isErrorEnabled());
System.out.println(logger4.isInfoEnabled());
org.apache.logging.log4j.spi.LoggerContext context=LogManager.getContext();
Logger logger = (Logger) LogManager.getLogger();
LoggerConfig config=logger.get();
Map<Property, Boolean> properties=config.getProperties();
System.out.println(config.getName());
LoggerContext ctx=LoggerContext.getContext();
Object appenders=ctx.getConfiguration().getAppenders();
System.out.println(appenders.toString());
}catch(Exception e){
e.printStackTrace();
}finally{
System.exit(0);
}
}