Search in sources :

Example 1 with AppenderConfigurationType

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

the class LoggingConfigurationManager method prepareCommonAppenderHeader.

private static void prepareCommonAppenderHeader(StringBuilder sb, AppenderConfigurationType appender, LoggingConfigurationType config, String appenderClass) {
    sb.append("\t<appender name=\"").append(appender.getName()).append("\" class=\"" + appenderClass + "\">\n");
    //Apply profiling appender filter if necessary
    if (IDM_PROFILE_APPENDER.equals(appender.getName())) {
        for (ClassLoggerConfigurationType cs : config.getClassLogger()) {
            if (REQUEST_FILTER_LOGGER_CLASS_NAME.equals(cs.getPackage()) || PROFILING_ASPECT_LOGGER.endsWith(cs.getPackage())) {
                LOGGER.debug("Defining ProfilingLogbackFilter to {} appender.", appender.getName());
                sb.append(defineProfilingLogbackFilter());
            }
        }
    }
}
Also used : ClassLoggerConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ClassLoggerConfigurationType)

Example 2 with AppenderConfigurationType

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

the class SystemConfigurationDto method init.

private void init(SystemConfigurationType config) {
    if (config == null) {
        return;
    }
    if (config.getGlobalAccountSynchronizationSettings() != null) {
        AssignmentPolicyEnforcementType globalAEP = config.getGlobalAccountSynchronizationSettings().getAssignmentPolicyEnforcement();
        aepLevel = AEPlevel.fromAEPLevelType(globalAEP);
    }
    CleanupPolicyType auditCleanup = config.getCleanupPolicy().getAuditRecords();
    CleanupPolicyType taskCleanup = config.getCleanupPolicy().getClosedTasks();
    auditCleanupValue = auditCleanup.getMaxAge().toString();
    taskCleanupValue = taskCleanup.getMaxAge().toString();
    passPolicyDto = loadPasswordPolicy(config);
    securityPolicyDto = loadSecurityPolicy(config);
    objectPolicyList = new ArrayList<>();
    List<ObjectPolicyConfigurationType> objectPolicies = config.getDefaultObjectPolicyConfiguration();
    if (objectPolicies != null && !objectPolicies.isEmpty()) {
        for (ObjectPolicyConfigurationType policy : objectPolicies) {
            objectPolicyList.add(new ObjectPolicyConfigurationTypeDto(policy));
        }
    } else {
        objectPolicyList.add(new ObjectPolicyConfigurationTypeDto());
    }
    // NOTIFICATIONS
    if (config.getNotificationConfiguration() != null) {
        notificationConfig = new NotificationConfigurationDto(config.getNotificationConfiguration());
    } else {
        notificationConfig = new NotificationConfigurationDto();
    }
    // LOGGING
    LoggingConfigurationType logging = config.getLogging();
    if (logging != null) {
        for (AppenderConfigurationType appender : logging.getAppender()) {
            if (appender instanceof FileAppenderConfigurationType) {
                appenders.add(new FileAppenderConfig((FileAppenderConfigurationType) appender));
            } else {
                appenders.add(new AppenderConfiguration(appender));
            }
        }
        Collections.sort(appenders);
        loggingConfig = new LoggingDto(config.getLogging());
    } else {
        loggingConfig = new LoggingDto();
    }
    loggingConfig.setAppenders(appenders);
    // PROFILING
    if (config.getProfilingConfiguration() != null) {
        List<ClassLoggerConfigurationType> classLoggerConfig = config.getLogging() != null ? config.getLogging().getClassLogger() : null;
        profilingDto = new ProfilingDto(config.getProfilingConfiguration(), classLoggerConfig);
    } else {
        profilingDto = new ProfilingDto();
    }
    profilingDto.setAppenders(appenders);
    enableExperimentalCode = SystemConfigurationTypeUtil.isExperimentalCodeEnabled(config);
    userDashboardLink = loadUserDashboardLink(config);
    additionalMenuLink = loadAdditionalMenuItem(config);
}
Also used : CleanupPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.CleanupPolicyType) AssignmentPolicyEnforcementType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType) ClassLoggerConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ClassLoggerConfigurationType) FileAppenderConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.FileAppenderConfigurationType) FileAppenderConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.FileAppenderConfigurationType) AppenderConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.AppenderConfigurationType) ObjectPolicyConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectPolicyConfigurationType) LoggingConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType)

Example 3 with AppenderConfigurationType

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

the class LoggingConfigPanel method addConsoleAppenderPerformed.

private void addConsoleAppenderPerformed(AjaxRequestTarget target) {
    LoggingDto dto = getModel().getObject();
    AppenderConfiguration appender = new AppenderConfiguration(new AppenderConfigurationType());
    appender.setEditing(true);
    dto.getAppenders().add(appender);
    target.add(getAppendersTable());
}
Also used : FileAppenderConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.FileAppenderConfigurationType) AppenderConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.AppenderConfigurationType) AppenderConfiguration(com.evolveum.midpoint.web.page.admin.configuration.dto.AppenderConfiguration) LoggingDto(com.evolveum.midpoint.web.page.admin.configuration.dto.LoggingDto)

Example 4 with AppenderConfigurationType

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

the class LoggingConfigPanel method initLoggerColumns.

private List<IColumn<LoggerConfiguration, String>> initLoggerColumns() {
    List<IColumn<LoggerConfiguration, String>> columns = new ArrayList<>();
    IColumn column = new CheckBoxHeaderColumn<LoggerConfiguration>();
    columns.add(column);
    //name editing column
    columns.add(new EditableLinkColumn<LoggerConfiguration>(createStringResource("LoggingConfigPanel.logger"), "name") {

        @Override
        protected Component createInputPanel(String componentId, final IModel<LoggerConfiguration> model) {
            if (model.getObject() instanceof StandardLogger) {
                DropDownChoicePanel dropDownChoicePanel = new DropDownChoicePanel(componentId, new PropertyModel(model, "logger"), WebComponentUtil.createReadonlyModelFromEnum(StandardLoggerType.class), new EnumChoiceRenderer<StandardLoggerType>());
                FormComponent<StandardLoggerType> input = dropDownChoicePanel.getBaseFormComponent();
                input.add(new NotNullValidator<StandardLoggerType>("logger.emptyLogger"));
                input.add(new AttributeAppender("style", "width: 100%"));
                input.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
                addAjaxFormComponentUpdatingBehavior(input);
                return dropDownChoicePanel;
            } else if (model.getObject() instanceof ComponentLogger) {
                DropDownChoicePanel dropDownChoicePanel = new DropDownChoicePanel(componentId, new PropertyModel(model, "component"), WebComponentUtil.createReadonlyModelFromEnum(LoggingComponentType.class), new EnumChoiceRenderer<LoggingComponentType>());
                FormComponent<LoggingComponentType> input = dropDownChoicePanel.getBaseFormComponent();
                input.add(new NotNullValidator<LoggingComponentType>("logger.emptyLogger"));
                input.add(new AttributeAppender("style", "width: 100%"));
                input.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
                addAjaxFormComponentUpdatingBehavior(input);
                return dropDownChoicePanel;
            } else {
                TextPanel textPanel = new TextPanel<>(componentId, new PropertyModel<String>(model, getPropertyExpression()));
                FormComponent input = textPanel.getBaseFormComponent();
                addAjaxFormComponentUpdatingBehavior(input);
                input.add(new AttributeAppender("style", "width: 100%"));
                input.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
                input.add(new NotNullValidator<StandardLoggerType>("message.emptyString"));
                return textPanel;
            }
        }

        @Override
        public void onClick(AjaxRequestTarget target, IModel<LoggerConfiguration> rowModel) {
            loggerEditPerformed(target, rowModel);
        }
    });
    //level editing column
    columns.add(new EditableLinkColumn<LoggerConfiguration>(createStringResource("LoggingConfigPanel.loggersLevel"), "level") {

        @Override
        protected Component createInputPanel(String componentId, IModel<LoggerConfiguration> model) {
            DropDownChoicePanel dropDownChoicePanel = new DropDownChoicePanel(componentId, new PropertyModel(model, getPropertyExpression()), WebComponentUtil.createReadonlyModelFromEnum(LoggingLevelType.class));
            FormComponent<LoggingLevelType> input = dropDownChoicePanel.getBaseFormComponent();
            input.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
            input.add(new NotNullValidator<LoggingLevelType>("message.emptyLevel"));
            addAjaxFormComponentUpdatingBehavior(input);
            return dropDownChoicePanel;
        }

        @Override
        public void onClick(AjaxRequestTarget target, IModel<LoggerConfiguration> rowModel) {
            loggerEditPerformed(target, rowModel);
        }

        @Override
        protected IModel<String> createLinkModel(IModel<LoggerConfiguration> rowModel) {
            LoggerConfiguration configuration = rowModel.getObject();
            return WebComponentUtil.createLocalizedModelForEnum(configuration.getLevel(), getPageBase());
        }
    });
    //appender editing column
    columns.add(new EditableLinkColumn<LoggerConfiguration>(createStringResource("LoggingConfigPanel.loggersAppender"), "appenders") {

        @Override
        protected IModel<String> createLinkModel(IModel<LoggerConfiguration> rowModel) {
            final LoggerConfiguration configuration = rowModel.getObject();
            if (configuration.getAppenders().isEmpty()) {
                return createStringResource("LoggingConfigPanel.appenders.Inherit");
            } else {
                return new LoadableModel<String>() {

                    @Override
                    protected String load() {
                        StringBuilder builder = new StringBuilder();
                        for (String appender : configuration.getAppenders()) {
                            if (configuration.getAppenders().indexOf(appender) != 0) {
                                builder.append(", ");
                            }
                            builder.append(appender);
                        }
                        return builder.toString();
                    }
                };
            }
        }

        @Override
        protected InputPanel createInputPanel(String componentId, IModel<LoggerConfiguration> model) {
            IModel<Map<String, String>> options = new Model(null);
            Map<String, String> optionsMap = new HashMap<String, String>();
            optionsMap.put("nonSelectedText", createStringResource("LoggingConfigPanel.appenders.Inherit").getString());
            options.setObject(optionsMap);
            ListMultipleChoicePanel panel = new ListMultipleChoicePanel<>(componentId, new PropertyModel<List<String>>(model, getPropertyExpression()), createNewLoggerAppendersListModel(), new StringChoiceRenderer(null), options);
            FormComponent<AppenderConfigurationType> input = panel.getBaseFormComponent();
            input.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
            addAjaxFormComponentUpdatingBehavior(input);
            return panel;
        }

        public void onClick(AjaxRequestTarget target, IModel<LoggerConfiguration> rowModel) {
            loggerEditPerformed(target, rowModel);
        }
    });
    return columns;
}
Also used : FormComponent(org.apache.wicket.markup.html.form.FormComponent) DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) EnumChoiceRenderer(org.apache.wicket.markup.html.form.EnumChoiceRenderer) ArrayList(java.util.ArrayList) TextPanel(com.evolveum.midpoint.web.component.input.TextPanel) ListMultipleChoicePanel(com.evolveum.midpoint.web.component.input.ListMultipleChoicePanel) CheckBoxHeaderColumn(com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn) Component(org.apache.wicket.Component) FormComponent(org.apache.wicket.markup.html.form.FormComponent) AttributeAppender(org.apache.wicket.behavior.AttributeAppender) LoggerConfiguration(com.evolveum.midpoint.web.page.admin.configuration.dto.LoggerConfiguration) StandardLoggerType(com.evolveum.midpoint.web.page.admin.configuration.dto.StandardLoggerType) StandardLogger(com.evolveum.midpoint.web.page.admin.configuration.dto.StandardLogger) IModel(org.apache.wicket.model.IModel) InputPanel(com.evolveum.midpoint.web.component.prism.InputPanel) PropertyModel(org.apache.wicket.model.PropertyModel) NotNullValidator(com.evolveum.midpoint.web.component.input.validator.NotNullValidator) ComponentLogger(com.evolveum.midpoint.web.page.admin.configuration.dto.ComponentLogger) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) StringChoiceRenderer(com.evolveum.midpoint.web.component.input.StringChoiceRenderer) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) IModel(org.apache.wicket.model.IModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) LoggingComponentType(com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingComponentType) Map(java.util.Map) HashMap(java.util.HashMap)

Example 5 with AppenderConfigurationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AppenderConfigurationType 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)

Aggregations

AppenderConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.AppenderConfigurationType)3 ClassLoggerConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ClassLoggerConfigurationType)3 FileAppenderConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.FileAppenderConfigurationType)3 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1 CheckBoxHeaderColumn (com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn)1 DropDownChoicePanel (com.evolveum.midpoint.web.component.input.DropDownChoicePanel)1 ListMultipleChoicePanel (com.evolveum.midpoint.web.component.input.ListMultipleChoicePanel)1 StringChoiceRenderer (com.evolveum.midpoint.web.component.input.StringChoiceRenderer)1 TextPanel (com.evolveum.midpoint.web.component.input.TextPanel)1 NotNullValidator (com.evolveum.midpoint.web.component.input.validator.NotNullValidator)1 InputPanel (com.evolveum.midpoint.web.component.prism.InputPanel)1 AppenderConfiguration (com.evolveum.midpoint.web.page.admin.configuration.dto.AppenderConfiguration)1 ComponentLogger (com.evolveum.midpoint.web.page.admin.configuration.dto.ComponentLogger)1 LoggerConfiguration (com.evolveum.midpoint.web.page.admin.configuration.dto.LoggerConfiguration)1 LoggingDto (com.evolveum.midpoint.web.page.admin.configuration.dto.LoggingDto)1 StandardLogger (com.evolveum.midpoint.web.page.admin.configuration.dto.StandardLogger)1 StandardLoggerType (com.evolveum.midpoint.web.page.admin.configuration.dto.StandardLoggerType)1 AssignmentPolicyEnforcementType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType)1 CleanupPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.CleanupPolicyType)1 LoggingComponentType (com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingComponentType)1