本文整理匯總了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);
}
}