All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zodiac.monitor.logging.LogConfiguration Maven / Gradle / Ivy

package org.zodiac.monitor.logging;

import org.springframework.core.env.Environment;
import org.zodiac.commons.constants.SystemPropertiesConstants;
import org.zodiac.monitor.MonitorConfigSpringApplicationRunListener;

public abstract class LogConfiguration {

    protected final Environment env;

    protected static final String LOGBACK_PATTERN =
        "[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] [%-5level] [%logger{40}] [%tid] - %msg%n";

    protected static final String LOG4J2_PATTERN =
        "[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] [%-5level] [%logger{40}] [%traceId] - %msg%n";

    protected String getBootstrapservers() {
        return MonitorConfigSpringApplicationRunListener
            .getConfig(SystemPropertiesConstants.Zodiac.MANAGEMENT_EXPORT_LOG_KAFKA_BOOTSTRAPSERVERS, null);
    }

    protected String getKafkaTopic() {
        return MonitorConfigSpringApplicationRunListener
            .getConfig(SystemPropertiesConstants.Zodiac.MANAGEMENT_EXPORT_LOG_KAFKA_TOPIC, "bizlog");
    }

    protected String getLogBackPattern() {
        return env.getProperty(SystemPropertiesConstants.Zodiac.MANAGEMENT_EXPORT_LOGS_PATTERN, LOGBACK_PATTERN);
    }

    protected String getLog4jPattern() {
        return env.getProperty(SystemPropertiesConstants.Zodiac.MANAGEMENT_EXPORT_LOGS_PATTERN, LOG4J2_PATTERN);
    }

    public LogConfiguration(Environment env) {
        this.env = env;
    }

    public abstract void init();

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy