Java Code Examples for org.apache.logging.log4j.LogManager#ROOT_LOGGER_NAME

The following examples show how to use org.apache.logging.log4j.LogManager#ROOT_LOGGER_NAME . 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: LoggerConfig.java    From logging-log4j2 with Apache License 2.0 6 votes vote down vote up
@PluginFactory
public static LoggerConfig createLogger(
        // @formatter:off
        @PluginAttribute final String additivity,
        @PluginAttribute final Level level,
        @PluginAttribute final String includeLocation,
        @PluginElement final AppenderRef[] refs,
        @PluginElement final Property[] properties,
        @PluginConfiguration final Configuration config,
        @PluginElement final Filter filter) {
        // @formatter:on
    final List<AppenderRef> appenderRefs = Arrays.asList(refs);
    final Level actualLevel = level == null ? Level.ERROR : level;
    final boolean additive = Booleans.parseBoolean(additivity, true);

    return new LoggerConfig(LogManager.ROOT_LOGGER_NAME, appenderRefs, filter, actualLevel, additive,
            properties, config, includeLocation(includeLocation, config));
}
 
Example 2
Source File: AsyncLoggerConfig.java    From logging-log4j2 with Apache License 2.0 6 votes vote down vote up
/**
 * @since 3.0
 */
@PluginFactory
public static LoggerConfig createLogger(
        @PluginAttribute final String additivity,
        @PluginAttribute final Level level,
        @PluginAttribute final String includeLocation,
        @PluginElement final AppenderRef[] refs,
        @PluginElement final Property[] properties,
        @PluginConfiguration final Configuration config,
        @PluginElement final Filter filter) {
    final List<AppenderRef> appenderRefs = Arrays.asList(refs);
    final Level actualLevel = level == null ? Level.ERROR : level;
    final boolean additive = Booleans.parseBoolean(additivity, true);
    return new AsyncLoggerConfig(LogManager.ROOT_LOGGER_NAME, appenderRefs, filter, actualLevel, additive,
            properties, config, AsyncLoggerConfig.includeLocation(includeLocation));
}
 
Example 3
Source File: Log4j2LoggerSpaceFactory.java    From sofa-common-tools with Apache License 2.0 5 votes vote down vote up
@Override
public Logger setLevel(String loggerName, AdapterLevel adapterLevel) {
    final String key = Logger.ROOT_LOGGER_NAME.equals(loggerName) ? LogManager.ROOT_LOGGER_NAME
        : loggerName;
    org.apache.logging.log4j.core.Logger log4j2Logger = loggerContext.getLogger(key);
    org.apache.logging.log4j.Level log4j2Level = this.toLog4j2Level(adapterLevel);
    log4j2Logger.setLevel(log4j2Level);
    return getLogger(loggerName);
}
 
Example 4
Source File: Log4j2LoggerSpaceFactory.java    From sofa-common-tools with Apache License 2.0 4 votes vote down vote up
private Logger newLogger(String name, LoggerContext loggerContext) {
    final String key = Logger.ROOT_LOGGER_NAME.equals(name) ? LogManager.ROOT_LOGGER_NAME
        : name;
    return new Log4jLogger(loggerContext.getLogger(key), name);
}
 
Example 5
Source File: Log4j2Helper.java    From arthas with Apache License 2.0 4 votes vote down vote up
private static LoggerConfig getLoggerConfig(String name) {
    if (!hasLength(name) || LoggerConfig.ROOT.equalsIgnoreCase(name)) {
        name = LogManager.ROOT_LOGGER_NAME;
    }
    return getLoggerContext().getConfiguration().getLoggers().get(name);
}
 
Example 6
Source File: Log4jLoggerFactory.java    From logging-log4j2 with Apache License 2.0 4 votes vote down vote up
@Override
protected Logger newLogger(final String name, final LoggerContext context) {
    final String key = Logger.ROOT_LOGGER_NAME.equals(name) ? LogManager.ROOT_LOGGER_NAME : name;
    return new Log4jLogger(markerFactory, validateContext(context).getLogger(key), name);
}
 
Example 7
Source File: Log4jLoggerFactory.java    From logging-log4j2 with Apache License 2.0 4 votes vote down vote up
@Override
protected Logger newLogger(final String name, final LoggerContext context) {
    final String key = Logger.ROOT_LOGGER_NAME.equals(name) ? LogManager.ROOT_LOGGER_NAME : name;
    return new Log4jLogger(validateContext(context).getLogger(key), name);
}