Search in sources :

Example 1 with SubSystemLoggerConfigurationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SubSystemLoggerConfigurationType in project midpoint by Evolveum.

the class FilterConfiguration method toXmlType.

public SubSystemLoggerConfigurationType toXmlType() {
    SubSystemLoggerConfigurationType type = new SubSystemLoggerConfigurationType();
    type.setComponent(component);
    type.setLevel(getLevel());
    type.getAppender().addAll(getAppenders());
    return type;
}
Also used : SubSystemLoggerConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SubSystemLoggerConfigurationType)

Example 2 with SubSystemLoggerConfigurationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SubSystemLoggerConfigurationType in project midpoint by Evolveum.

the class LoggingDto method init.

private void init(LoggingConfigurationType config) {
    if (config == null) {
        return;
    }
    rootLevel = config.getRootLoggerLevel();
    rootAppender = config.getRootLoggerAppender();
    for (SubSystemLoggerConfigurationType logger : config.getSubSystemLogger()) {
        filters.add(new FilterConfiguration(logger));
    }
    AuditingConfigurationType auditing = config.getAuditing();
    if (auditing != null) {
        setAuditLog(auditing.isEnabled());
        setAuditDetails(auditing.isDetails());
        setAuditAppender(auditing.getAppender() != null && auditing.getAppender().size() > 0 ? auditing.getAppender().get(0) : null);
    }
    for (ClassLoggerConfigurationType logger : config.getClassLogger()) {
        if (ProfilingDto.LOGGER_PROFILING.equals(logger.getPackage())) {
            continue;
        }
        if (componentMap.containsKey(logger.getPackage())) {
            loggers.add(new ComponentLogger(logger));
        } else if (StandardLogger.isStandardLogger(logger.getPackage())) {
            loggers.add(new StandardLogger(logger));
        } else {
            loggers.add(new ClassLogger(logger));
        }
    }
    Collections.sort(loggers, new Comparator<LoggerConfiguration>() {

        @Override
        public int compare(LoggerConfiguration l1, LoggerConfiguration l2) {
            return String.CASE_INSENSITIVE_ORDER.compare(l1.getName(), l2.getName());
        }
    });
    Collections.sort(filters, new Comparator<FilterConfiguration>() {

        @Override
        public int compare(FilterConfiguration f1, FilterConfiguration f2) {
            return String.CASE_INSENSITIVE_ORDER.compare(f1.getName(), f2.getName());
        }
    });
}
Also used : AuditingConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.AuditingConfigurationType) ClassLoggerConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ClassLoggerConfigurationType) SubSystemLoggerConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SubSystemLoggerConfigurationType)

Example 3 with SubSystemLoggerConfigurationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SubSystemLoggerConfigurationType in project midpoint by Evolveum.

the class LoggingDto method getNewObject.

public LoggingConfigurationType getNewObject() {
    LoggingConfigurationType configuration = new LoggingConfigurationType();
    AuditingConfigurationType audit = new AuditingConfigurationType();
    audit.setEnabled(isAuditLog());
    audit.setDetails(isAuditDetails());
    if (StringUtils.isNotEmpty(getAuditAppender())) {
        audit.getAppender().add(getAuditAppender());
    }
    configuration.setAuditing(audit);
    configuration.setRootLoggerAppender(getRootAppender());
    configuration.setRootLoggerLevel(getRootLevel());
    for (AppenderConfiguration item : getAppenders()) {
        configuration.getAppender().add(item.getConfig());
    }
    for (LoggerConfiguration item : getLoggers()) {
        for (ClassLoggerConfigurationType logger : configuration.getClassLogger()) {
            if (logger.getPackage().equals(item.getName())) {
                throw new IllegalStateException("Logger with name '" + item.getName() + "' is already defined.");
            }
        }
        //TODO : clean up toXmlType() method.. getAppenders() in LogginConfiguration is empty by default..shouldn't it be null?
        if (item.toXmlType() != null) {
            configuration.getClassLogger().add(item.toXmlType());
        }
    }
    for (FilterConfiguration item : getFilters()) {
        for (SubSystemLoggerConfigurationType filter : configuration.getSubSystemLogger()) {
            if (filter.getComponent().name().equals(item.getName())) {
                throw new IllegalStateException("Filter with name '" + item.getName() + "' is already defined.");
            }
        }
        configuration.getSubSystemLogger().add(item.toXmlType());
    }
    for (LoggerConfiguration logger : getLoggers()) {
        logger.setEditing(false);
    }
    for (FilterConfiguration filter : getFilters()) {
        filter.setEditing(false);
    }
    for (AppenderConfiguration appender : getAppenders()) {
        appender.setEditing(false);
    }
    return configuration;
}
Also used : AuditingConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.AuditingConfigurationType) LoggingConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType) ClassLoggerConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ClassLoggerConfigurationType) SubSystemLoggerConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SubSystemLoggerConfigurationType)

Example 4 with SubSystemLoggerConfigurationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SubSystemLoggerConfigurationType in project midpoint by Evolveum.

the class LoggingConfigurationManager method prepareConfiguration.

private static String prepareConfiguration(LoggingConfigurationType config) throws SchemaException {
    if (null == config) {
        throw new IllegalArgumentException("Configuration can't be null");
    }
    StringBuilder sb = new StringBuilder();
    sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
    sb.append("<configuration scan=\"false\" debug=\"true\">\n");
    //find and configure ALL logger and bring it to top of turbo stack
    for (SubSystemLoggerConfigurationType ss : config.getSubSystemLogger()) {
        if ("ALL".contentEquals(ss.getComponent().name())) {
            defineTurbo(sb, ss);
        }
    }
    //Generate subsystem logging quickstep
    for (SubSystemLoggerConfigurationType ss : config.getSubSystemLogger()) {
        if (null == ss.getComponent() || null == ss.getLevel()) {
            LOGGER.error("Subsystem ({}) or level ({})is null", ss.getComponent(), ss.getLevel());
            continue;
        }
        //skip disabled subsystem logger
        if ("OFF".equals(ss.getLevel().name())) {
            continue;
        }
        //All ready defined above
        if ("ALL".contentEquals(ss.getComponent().name())) {
            continue;
        }
        defineTurbo(sb, ss);
    }
    //Generate appenders configuration
    for (AppenderConfigurationType appender : config.getAppender()) {
        prepareAppenderConfiguration(sb, appender, config);
    }
    //define root appender if defined
    if (!StringUtils.isEmpty(config.getRootLoggerAppender())) {
        sb.append("\t<root level=\"");
        sb.append(config.getRootLoggerLevel());
        sb.append("\">\n");
        sb.append("\t\t<appender-ref ref=\"");
        sb.append(config.getRootLoggerAppender());
        sb.append("\" />\n");
        sb.append("\t</root>\n");
    }
    //Generate class based loggers
    for (ClassLoggerConfigurationType logger : config.getClassLogger()) {
        sb.append("\t<logger name=\"");
        sb.append(logger.getPackage());
        sb.append("\" level=\"");
        sb.append(logger.getLevel());
        sb.append("\"");
        //if logger specific appender is defined
        if (null != logger.getAppender() && !logger.getAppender().isEmpty()) {
            sb.append(" additivity=\"false\">\n");
            for (String appenderName : logger.getAppender()) {
                sb.append("\t\t<appender-ref ref=\"");
                sb.append(appenderName);
                sb.append("\"/>");
            }
            sb.append("\t</logger>\n");
        } else {
            sb.append("/>\n");
        }
    }
    generateAuditingLogConfig(config.getAuditing(), sb);
    if (null != config.getAdvanced()) {
        for (Object item : config.getAdvanced().getContent()) {
            sb.append(item.toString());
            sb.append("\n");
        }
    }
    // LevelChangePropagator to propagate log level changes to JUL
    // this keeps us from performance impact of disable JUL logging statements
    // WARNING: if deployed in Tomcat then this propagates only to the JUL loggers in current classloader.
    // It means that ICF connector loggers are not affected by this
    // MAGIC: moved to the end of the "file" as suggested in http://jira.qos.ch/browse/LOGBACK-740
    sb.append("\t<contextListener class=\"ch.qos.logback.classic.jul.LevelChangePropagator\">\n");
    sb.append("\t\t<resetJUL>true</resetJUL>\n");
    sb.append("\t</contextListener>\n");
    sb.append("</configuration>");
    return sb.toString();
}
Also used : SyslogAppenderConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SyslogAppenderConfigurationType) FileAppenderConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.FileAppenderConfigurationType) AppenderConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.AppenderConfigurationType) ClassLoggerConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ClassLoggerConfigurationType) SubSystemLoggerConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SubSystemLoggerConfigurationType)

Example 5 with SubSystemLoggerConfigurationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SubSystemLoggerConfigurationType in project midpoint by Evolveum.

the class TestLoggingConfiguration method test010AddModelSubsystemLogger.

@Test
public void test010AddModelSubsystemLogger() throws Exception {
    final String TEST_NAME = "test010AddModelSubsystemLogger";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME);
    Task task = taskManager.createTaskInstance(TestLoggingConfiguration.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // Precondition
    tailer.logAndTail();
    assertBasicLogging(tailer);
    tailer.assertMarkerNotLogged(LogfileTestTailer.LEVEL_DEBUG, ProfilingDataManager.Subsystem.MODEL.name());
    tailer.assertMarkerNotLogged(LogfileTestTailer.LEVEL_TRACE, ProfilingDataManager.Subsystem.MODEL.name());
    // Setup
    PrismObject<SystemConfigurationType> systemConfiguration = PrismTestUtil.parseObject(AbstractInitializedModelIntegrationTest.SYSTEM_CONFIGURATION_FILE);
    LoggingConfigurationType logging = systemConfiguration.asObjectable().getLogging();
    applyTestLoggingConfig(logging);
    SubSystemLoggerConfigurationType modelSubSystemLogger = new SubSystemLoggerConfigurationType();
    modelSubSystemLogger.setComponent(LoggingComponentType.MODEL);
    modelSubSystemLogger.setLevel(LoggingLevelType.DEBUG);
    logging.getSubSystemLogger().add(modelSubSystemLogger);
    ObjectDelta<SystemConfigurationType> systemConfigDelta = ObjectDelta.createModificationReplaceProperty(SystemConfigurationType.class, AbstractInitializedModelIntegrationTest.SYSTEM_CONFIGURATION_OID, SystemConfigurationType.F_LOGGING, prismContext, logging);
    Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(systemConfigDelta);
    // WHEN
    modelService.executeChanges(deltas, null, task, result);
    // THEN
    tailer.logAndTail();
    assertBasicLogging(tailer);
    tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_DEBUG, ProfilingDataManager.Subsystem.MODEL.name());
    tailer.assertMarkerNotLogged(LogfileTestTailer.LEVEL_TRACE, ProfilingDataManager.Subsystem.MODEL.name());
    // Test that the class logger for this test messages works
    // GIVEN
    tailer.setExpecteMessage("This is THE MESSage");
    // WHEN
    display("This is THE MESSage");
    // THEN
    tailer.tail();
    tailer.assertExpectedMessage();
    tailer.close();
}
Also used : LogfileTestTailer(com.evolveum.midpoint.test.util.LogfileTestTailer) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) LoggingConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) SubSystemLoggerConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SubSystemLoggerConfigurationType) Test(org.testng.annotations.Test)

Aggregations

SubSystemLoggerConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SubSystemLoggerConfigurationType)6 ClassLoggerConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ClassLoggerConfigurationType)3 LoggingConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType)3 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 Task (com.evolveum.midpoint.task.api.Task)2 LogfileTestTailer (com.evolveum.midpoint.test.util.LogfileTestTailer)2 AuditingConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.AuditingConfigurationType)2 SystemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)2 Test (org.testng.annotations.Test)2 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)1 AppenderConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.AppenderConfigurationType)1 FileAppenderConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.FileAppenderConfigurationType)1 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)1 SyslogAppenderConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SyslogAppenderConfigurationType)1