Search in sources :

Example 1 with LogLevel

use of com.torodb.packaging.config.model.generic.LogLevel in project torodb by torodb.

the class Log4jUtils method setLevel.

private static void setLevel(Logger logger, LogLevel logLevel) {
    Level log4jLevel = Log4jLevelToLogLevelMapper.map(logLevel);
    logger.setLevel(log4jLevel);
}
Also used : Level(org.apache.logging.log4j.Level) LogLevel(com.torodb.packaging.config.model.generic.LogLevel)

Example 2 with LogLevel

use of com.torodb.packaging.config.model.generic.LogLevel in project torodb by torodb.

the class Log4jUtils method setLevel.

private static void setLevel(LoggerConfig loggerConfig, LogLevel logLevel) {
    Level log4jLevel = Log4jLevelToLogLevelMapper.map(logLevel);
    loggerConfig.setLevel(log4jLevel);
}
Also used : Level(org.apache.logging.log4j.Level) LogLevel(com.torodb.packaging.config.model.generic.LogLevel)

Example 3 with LogLevel

use of com.torodb.packaging.config.model.generic.LogLevel in project torodb by torodb.

the class Log4jUtils method setLogPackages.

public static void setLogPackages(Map<String, LogLevel> logPackages) {
    for (Map.Entry<String, LogLevel> logPackage : logPackages.entrySet()) {
        LoggerContext coreContext = (LoggerContext) LogManager.getContext(false);
        Logger logger = coreContext.getLogger(logPackage.getKey());
        setLevel(logger, logPackage.getValue());
    }
}
Also used : Logger(org.apache.logging.log4j.core.Logger) Map(java.util.Map) LoggerContext(org.apache.logging.log4j.core.LoggerContext) LogLevel(com.torodb.packaging.config.model.generic.LogLevel)

Example 4 with LogLevel

use of com.torodb.packaging.config.model.generic.LogLevel in project torodb by torodb.

the class ConfigTest method testParseWithLogPackagesParam.

@Test
public void testParseWithLogPackagesParam() throws Exception {
    final String logPackage = "com.torodb";
    final LogLevel level = LogLevel.NONE;
    CliConfig cliConfig = new CliConfig() {

        @Override
        public List<String> getParams() {
            String[] params = new String[] { "/logging/packages/" + logPackage + "=" + level.name() };
            return Arrays.asList(params);
        }
    };
    Config config = CliConfigUtils.readConfig(cliConfig);
    Assert.assertTrue("/logging/packages not defined", config.getLogging().getPackages() != null);
    Assert.assertTrue("/logging/packages/" + logPackage + " not defined", config.getLogging().getPackages().get(logPackage) != null);
    Assert.assertEquals("/logging/packages has not 1 entry", 1, config.getLogging().getPackages().size());
    Assert.assertEquals("/logging/packages/" + logPackage + " has different value than that specified", level, config.getLogging().getPackages().get(logPackage));
}
Also used : CliConfig(com.torodb.stampede.CliConfig) Config(com.torodb.stampede.config.model.Config) CliConfig(com.torodb.stampede.CliConfig) LogLevel(com.torodb.packaging.config.model.generic.LogLevel) Test(org.junit.Test)

Example 5 with LogLevel

use of com.torodb.packaging.config.model.generic.LogLevel in project torodb by torodb.

the class ConfigTest method testParseWithLogPackagesParam.

@Test
public void testParseWithLogPackagesParam() throws Exception {
    final String logPackage = "com.torodb";
    final LogLevel logLevel = LogLevel.NONE;
    CliConfig cliConfig = new CliConfig() {

        @Override
        public List<String> getParams() {
            String[] params = new String[] { "/generic/logPackages/" + logPackage + "=" + logLevel.name() };
            return Arrays.asList(params);
        }
    };
    Config config = CliConfigUtils.readConfig(cliConfig);
    Assert.assertTrue("/generic/logPackages not defined", config.getGeneric().getLogPackages() != null);
    Assert.assertTrue("/generic/logPackages/" + logPackage + " not defined", config.getGeneric().getLogPackages().get(logPackage) != null);
    Assert.assertEquals("/generic/logPackages has not 1 entry", 1, config.getGeneric().getLogPackages().size());
    Assert.assertEquals("/generic/logPackages/" + logPackage + " has different value than that specified", logLevel, config.getGeneric().getLogPackages().get(logPackage));
}
Also used : Config(com.torodb.standalone.config.model.Config) CliConfig(com.torodb.standalone.CliConfig) CliConfig(com.torodb.standalone.CliConfig) LogLevel(com.torodb.packaging.config.model.generic.LogLevel) Test(org.junit.Test)

Aggregations

LogLevel (com.torodb.packaging.config.model.generic.LogLevel)5 Level (org.apache.logging.log4j.Level)2 Test (org.junit.Test)2 CliConfig (com.torodb.stampede.CliConfig)1 Config (com.torodb.stampede.config.model.Config)1 CliConfig (com.torodb.standalone.CliConfig)1 Config (com.torodb.standalone.config.model.Config)1 Map (java.util.Map)1 Logger (org.apache.logging.log4j.core.Logger)1 LoggerContext (org.apache.logging.log4j.core.LoggerContext)1