use of com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType in project midpoint by Evolveum.
the class TestLoggingConfiguration method applyTestLoggingConfig.
private void applyTestLoggingConfig(LoggingConfigurationType logging) {
// Make sure that this class has a special entry in the config so we will see the messages from this test code
ClassLoggerConfigurationType testClassLogger = new ClassLoggerConfigurationType();
testClassLogger.setPackage(TestLoggingConfiguration.class.getName());
testClassLogger.setLevel(LoggingLevelType.TRACE);
logging.getClassLogger().add(testClassLogger);
ClassLoggerConfigurationType integrationTestToolsLogger = new ClassLoggerConfigurationType();
integrationTestToolsLogger.setPackage(IntegrationTestTools.class.getName());
integrationTestToolsLogger.setLevel(LoggingLevelType.TRACE);
logging.getClassLogger().add(integrationTestToolsLogger);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType in project midpoint by Evolveum.
the class TestLoggingConfiguration method test002InitialConfiguration.
@Test
public void test002InitialConfiguration() throws Exception {
final String TEST_NAME = "test002InitialConfiguration";
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();
PrismObject<SystemConfigurationType> systemConfiguration = PrismTestUtil.parseObject(SYSTEM_CONFIGURATION_FILE);
LoggingConfigurationType logging = systemConfiguration.asObjectable().getLogging();
applyTestLoggingConfig(logging);
SubSystemLoggerConfigurationType modelSubSystemLogger = new SubSystemLoggerConfigurationType();
modelSubSystemLogger.setComponent(LoggingComponentType.PROVISIONING);
modelSubSystemLogger.setLevel(LoggingLevelType.TRACE);
logging.getSubSystemLogger().add(modelSubSystemLogger);
PrismObjectDefinition<SystemConfigurationType> systemConfigurationTypeDefinition = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(SystemConfigurationType.class);
Collection<? extends ItemDelta> modifications = PropertyDelta.createModificationReplacePropertyCollection(SystemConfigurationType.F_LOGGING, systemConfigurationTypeDefinition, logging);
// Modify directly in repository, so the logging code in model will not notice the change
repositoryService.modifyObject(SystemConfigurationType.class, AbstractInitializedModelIntegrationTest.SYSTEM_CONFIGURATION_OID, modifications, result);
// precondition
tailer.logAndTail();
assertBasicLogging(tailer);
tailer.assertMarkerNotLogged(LogfileTestTailer.LEVEL_TRACE, ProfilingDataManager.Subsystem.PROVISIONING.name());
// WHEN
repositoryService.postInit(result);
modelService.postInit(result);
// THEN
tailer.logAndTail();
assertBasicLogging(tailer);
tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_TRACE, ProfilingDataManager.Subsystem.PROVISIONING.name());
tailer.close();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType in project midpoint by Evolveum.
the class TestLoggingConfiguration method test030ConnectorLogging.
/**
* Test if connectors log properly. The dummy connector logs on all levels when the
* "test" operation is invoked. So let's try it.
*/
@Test
public void test030ConnectorLogging() throws Exception {
final String TEST_NAME = "test030ConnectorLogging";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME);
// ICF logging is prefixing the messages;
tailer.setAllowPrefix(true);
Task task = taskManager.createTaskInstance(TestLoggingConfiguration.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
importObjectFromFile(RESOURCE_DUMMY_FILE, result);
// Setup
PrismObject<SystemConfigurationType> systemConfiguration = PrismTestUtil.parseObject(AbstractInitializedModelIntegrationTest.SYSTEM_CONFIGURATION_FILE);
LoggingConfigurationType logging = systemConfiguration.asObjectable().getLogging();
applyTestLoggingConfig(logging);
ClassLoggerConfigurationType classLogerCongif = new ClassLoggerConfigurationType();
classLogerCongif.setPackage(DummyConnector.class.getPackage().getName());
classLogerCongif.setLevel(LoggingLevelType.ALL);
logging.getClassLogger().add(classLogerCongif);
ObjectDelta<SystemConfigurationType> systemConfigDelta = ObjectDelta.createModificationReplaceProperty(SystemConfigurationType.class, AbstractInitializedModelIntegrationTest.SYSTEM_CONFIGURATION_OID, SystemConfigurationType.F_LOGGING, prismContext, logging);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(systemConfigDelta);
modelService.executeChanges(deltas, null, task, result);
// INFO part
java.util.logging.Logger dummyConnctorJulLogger = java.util.logging.Logger.getLogger(DummyConnector.class.getName());
LOGGER.info("Dummy connector JUL logger as seen by the test: {}; classloader {}", dummyConnctorJulLogger, dummyConnctorJulLogger.getClass().getClassLoader());
// WHEN
modelService.testResource(RESOURCE_DUMMY_OID, task);
// THEN
tailer.tail();
tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_ERROR, "DummyConnectorIcfError");
tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_WARN, "DummyConnectorIcfWarn");
tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_DEBUG, "DummyConnectorIcfInfo");
tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_TRACE, "DummyConnectorIcfOk");
tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_ERROR, "DummyConnectorJULsevere");
tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_WARN, "DummyConnectorJULwarning");
tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_INFO, "DummyConnectorJULinfo");
tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_DEBUG, "DummyConnectorJULfine");
tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_DEBUG, "DummyConnectorJULfiner");
tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_TRACE, "DummyConnectorJULfinest");
tailer.close();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType 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