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());
}
}
}
}
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);
}
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());
}
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;
}
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();
}
Aggregations