当前位置: 首页>>代码示例>>Java>>正文


Java ConfigurationSource.NULL_SOURCE属性代码示例

本文整理汇总了Java中org.apache.logging.log4j.core.config.ConfigurationSource.NULL_SOURCE属性的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationSource.NULL_SOURCE属性的具体用法?Java ConfigurationSource.NULL_SOURCE怎么用?Java ConfigurationSource.NULL_SOURCE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.logging.log4j.core.config.ConfigurationSource的用法示例。


在下文中一共展示了ConfigurationSource.NULL_SOURCE属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: EmbeddedConfiguration

/**
 * Ctor. The configuration is built using instance of
 * {@link Spec}:
 * 
 * <ul>
 * <li>The name is set to {@link Spec#getName()}.
 * <li>Appenders from the parent object are cleared.
 * <li>{@link Appender}s are created
 * {@link #buildAppenders(Spec)}.
 * <li>{@link LoggerConfig}s are created using
 * {@link #buildLoggerConfigs(Spec)}.
 * <li>Every {@link LoggerConfig} is configured with its
 * {@link Appender} using
 * {@link #configureLoggerAppenders(Spec, Map, Map)}.
 * <li>Root loggers are configured.
 * </ul>
 * 
 * @param spec
 */
EmbeddedConfiguration(Spec spec) {
  super(ConfigurationSource.NULL_SOURCE);
  setName(spec.getName());

  // Clean up first
  getAppenders().clear();
  getRootLogger().getAppenders().clear();

  // Build Appenders
  final Map<String, Appender> appenders = buildAppenders(spec);
  final Map<String, SyslogAppender> syslogAppenders = buildSyslogAppenders(spec);

  // Build Logger Configs
  final Map<String, LoggerConfig> loggers = buildLoggerConfigs(spec);

  // Configure loggers with appenders
  configureLoggerAppenders(spec, appenders, loggers);

  // Configure root logger appenders
  configureRootLogger(spec, appenders, syslogAppenders);
}
 
开发者ID:nobeh,项目名称:log4j-configuration-builder,代码行数:40,代码来源:ConfigurationBuilder.java

示例2: BasicConfiguration

public BasicConfiguration() {
    super(null, ConfigurationSource.NULL_SOURCE);

    final LoggerConfig root = getRootLogger();
    final String name = System.getProperty(DEFAULT_LEVEL);
    final Level level = (name != null && Level.getLevel(name) != null) ? Level.getLevel(name) : Level.ERROR;
    root.setLevel(level);
}
 
开发者ID:savantly-net,项目名称:log4j2-extended-jsonlayout,代码行数:8,代码来源:BasicConfigurationFactory.java

示例3: getConfiguration

@Override
public Configuration getConfiguration(LoggerContext loggerContext, ConfigurationSource source) {
    if (source != null && source != ConfigurationSource.NULL_SOURCE) {
        if (LoggingSystem.get(loggerContext.getClass().getClassLoader()) != null) {
            return new DefaultConfiguration();
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:logging-log4j-boot,代码行数:9,代码来源:PrebootConfigurationFactory.java

示例4: BasicConfiguration

public BasicConfiguration(final LoggerContext loggerContext) {
    super(loggerContext, ConfigurationSource.NULL_SOURCE);

    final LoggerConfig root = getRootLogger();
    setName("BasicConfiguration");
    final String levelName = System.getProperty(DEFAULT_LEVEL);
    final Level level = (levelName != null && Level.getLevel(levelName) != null) ? Level.getLevel(levelName)
            : Level.DEBUG;
    root.setLevel(level);
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:10,代码来源:BasicConfigurationFactory.java

示例5: CompositeConfiguration

/**
 * Construct the ComponsiteConfiguration.
 *
 * @param configurations The List of Configurations to merge.
 */
public CompositeConfiguration(final List<? extends AbstractConfiguration> configurations) {
    super(configurations.get(0).getLoggerContext(), ConfigurationSource.NULL_SOURCE);
    rootNode = configurations.get(0).getRootNode();
    this.configurations = configurations;
    final String mergeStrategyClassName = PropertiesUtil.getProperties().getStringProperty(MERGE_STRATEGY_PROPERTY,
            DefaultMergeStrategy.class.getName());
    try {
        mergeStrategy = LoaderUtil.newInstanceOf(mergeStrategyClassName);
    } catch (ClassNotFoundException | IllegalAccessException | NoSuchMethodException | InvocationTargetException |
            InstantiationException ex) {
        mergeStrategy = new DefaultMergeStrategy();
    }
    for (final AbstractConfiguration config : configurations) {
        mergeStrategy.mergeRootProperties(rootNode, config);
    }
    final StatusConfiguration statusConfig = new StatusConfiguration().withVerboseClasses(VERBOSE_CLASSES)
            .withStatus(getDefaultStatus());
    for (final Map.Entry<String, String> entry : rootNode.getAttributes().entrySet()) {
        final String key = entry.getKey();
        final String value = getStrSubstitutor().replace(entry.getValue());
        if ("status".equalsIgnoreCase(key)) {
            statusConfig.withStatus(value.toUpperCase());
        } else if ("dest".equalsIgnoreCase(key)) {
            statusConfig.withDestination(value);
        } else if ("shutdownHook".equalsIgnoreCase(key)) {
            isShutdownHookEnabled = !"disable".equalsIgnoreCase(value);
        } else if ("shutdownTimeout".equalsIgnoreCase(key)) {
            shutdownTimeoutMillis = Long.parseLong(value);
        } else if ("verbose".equalsIgnoreCase(key)) {
            statusConfig.withVerbosity(value);
        } else if ("packages".equalsIgnoreCase(key)) {
            pluginPackages.addAll(Arrays.asList(value.split(Patterns.COMMA_SEPARATOR)));
        } else if ("name".equalsIgnoreCase(key)) {
            setName(value);
        }
    }
    statusConfig.initialize();
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:43,代码来源:CompositeConfiguration.java

示例6: StandaloneLoggerConfiguration

public StandaloneLoggerConfiguration() {
    this(ConfigurationSource.NULL_SOURCE);
}
 
开发者ID:Steve973,项目名称:camel-standalone,代码行数:3,代码来源:StandaloneLoggerConfiguration.java

示例7: Log4J2Configuration

protected Log4J2Configuration(ConfigurationSource configurationSource)
{
	super(ConfigurationSource.NULL_SOURCE);
	
	  setName("Default");
	   PatternLayout layout = PatternLayout.newBuilder().withPattern(Log4J2.DEFALT_LAYOUT).withConfiguration(this).build();
        Appender appender = ConsoleAppender.createDefaultAppenderForLayout(layout);
        appender.start();
        addAppender(appender);
        
        String fileName = Config.getProperty(Log4J2.class,"file","");
        String append = Boolean.TRUE.toString();
        String locking = Boolean.TRUE.toString();
        
        String immediateFlush = Boolean.TRUE.toString();
        String ignore = Boolean.TRUE.toString();
        String bufferedIo = Boolean.TRUE.toString();
        String bufferSizeStr = "8192";
        Filter filter = null;
        String advertise = null;
        String advertiseUri = null;
        
        Appender fileAppender = null;
        if(fileName.length() >  0)
        {
        	String name = Config.getProperty(Log4J2.class,"name","default");
        	
        	 fileAppender = FileAppender.createAppender(fileName, append, locking, name, immediateFlush, ignore,
        			bufferedIo, bufferSizeStr, layout, filter, advertise, advertiseUri, this);
        	 
	        fileAppender.start();
	        addAppender(fileAppender);
	  
        }
        	   
        LoggerConfig root = getRootLogger();
        root.addAppender(appender, null, null);
        if(fileAppender != null)
        {
        	root.addAppender(fileAppender, null, filter);	
        }
        
        String levelName = PropertiesUtil.getProperties().getStringProperty("org.apache.logging.log4j.level");
        Level level = levelName == null || Level.valueOf(levelName) == null ? Level.DEBUG : Level.valueOf(levelName);
        root.setLevel(level);
}
 
开发者ID:nyla-solutions,项目名称:nyla,代码行数:46,代码来源:Log4J2ConfigurationFactory.java

示例8: CustomConfiguration

public CustomConfiguration(final LoggerContext loggerContext) {
    this(loggerContext, ConfigurationSource.NULL_SOURCE);
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:3,代码来源:CustomConfiguration.java

示例9: build

@Override
public T build(final boolean initialize) {
    T configuration;
    try {
        if (source == null) {
            source = ConfigurationSource.NULL_SOURCE;
        }
        final Constructor<T> constructor = clazz.getConstructor(LoggerContext.class, ConfigurationSource.class, Component.class);
        configuration = constructor.newInstance(loggerContext, source, root);
        configuration.setMonitorInterval(monitorInterval);
        configuration.getRootNode().getAttributes().putAll(root.getAttributes());
        if (name != null) {
            configuration.setName(name);
        }
        if (level != null) {
            configuration.getStatusConfiguration().withStatus(level);
        }
        if (verbosity != null) {
            configuration.getStatusConfiguration().withVerbosity(verbosity);
        }
        if (destination != null) {
            configuration.getStatusConfiguration().withDestination(destination);
        }
        if (packages != null) {
            configuration.setPluginPackages(packages);
        }
        if (shutdownFlag != null) {
            configuration.setShutdownHook(shutdownFlag);
        }
        if (shutdownTimeoutMillis > 0) {
            configuration.setShutdownTimeoutMillis(shutdownTimeoutMillis);
        }
        if (advertiser != null) {
            configuration.createAdvertiser(advertiser, source);
        }
    } catch (final Exception ex) {
        throw new IllegalArgumentException("Invalid Configuration class specified", ex);
    }
    configuration.getStatusConfiguration().initialize();
    if (initialize) {
        configuration.initialize();
    }
    return configuration;
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:44,代码来源:DefaultConfigurationBuilder.java


注:本文中的org.apache.logging.log4j.core.config.ConfigurationSource.NULL_SOURCE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。