Search in sources :

Example 1 with ConfigSource

use of org.apache.geode.internal.ConfigSource in project geode by apache.

the class LogWriterFactory method createLogWriterLogger.

/**
   * Creates the log writer for a distributed system based on the system's parsed configuration. The
   * initial banner and messages are also entered into the log by this method.
   * 
   * @param isLoner Whether the distributed system is a loner or not
   * @param isSecure Whether a logger for security related messages has to be created
   * @param config The DistributionConfig for the target distributed system
   * @param logConfig if true log the configuration
   */
public static InternalLogWriter createLogWriterLogger(final boolean isLoner, final boolean isSecure, final LogConfig config, final boolean logConfig) {
    // if isSecurity then use "org.apache.geode.security" else use "org.apache.geode"
    String name = null;
    if (isSecure) {
        name = LogService.SECURITY_LOGGER_NAME;
    } else {
        name = LogService.MAIN_LOGGER_NAME;
    }
    // create the LogWriterLogger
    final LogWriterLogger logger = LogService.createLogWriterLogger(name, config.getName(), isSecure);
    if (isSecure) {
        logger.setLogWriterLevel(((DistributionConfig) config).getSecurityLogLevel());
    } else {
        boolean defaultSource = false;
        if (config instanceof DistributionConfig) {
            ConfigSource source = ((DistributionConfig) config).getConfigSource(LOG_LEVEL);
            if (source == null) {
                defaultSource = true;
            }
        }
        if (!defaultSource) {
            // LOG: fix bug #51709 by not setting if log-level was not specified
            // LOG: let log4j2.xml specify log level which defaults to INFO
            logger.setLogWriterLevel(config.getLogLevel());
        }
    }
    // log the banner
    if (!Boolean.getBoolean(InternalLocator.INHIBIT_DM_BANNER)) {
        if (// avoid filling up logs
        InternalDistributedSystem.getReconnectAttemptCounter() == 0 && // during auto-reconnect
        !// && !isLoner /* do this on a loner to fix bug 35602 */
        isSecure) {
            // LOG:CONFIG:
            logger.info(LogMarker.CONFIG, Banner.getString(null));
        }
    } else {
        logger.debug("skipping banner - " + InternalLocator.INHIBIT_DM_BANNER + " is set to true");
    }
    // log the config
    if (logConfig) {
        if (!isLoner) {
            // LOG:CONFIG: changed from config to info
            logger.info(LogMarker.CONFIG, LocalizedMessage.create(LocalizedStrings.InternalDistributedSystem_STARTUP_CONFIGURATIONN_0, config.toLoggerString()));
        }
    }
    return logger;
}
Also used : ConfigSource(org.apache.geode.internal.ConfigSource) DistributionConfig(org.apache.geode.distributed.internal.DistributionConfig) LogWriterLogger(org.apache.geode.internal.logging.log4j.LogWriterLogger)

Aggregations

DistributionConfig (org.apache.geode.distributed.internal.DistributionConfig)1 ConfigSource (org.apache.geode.internal.ConfigSource)1 LogWriterLogger (org.apache.geode.internal.logging.log4j.LogWriterLogger)1