Java Code Examples for org.jboss.logmanager.LogContext#getLogContext()
The following examples show how to use
org.jboss.logmanager.LogContext#getLogContext() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LoggingConfigurationFileReloader.java From activemq-artemis with Apache License 2.0 | 6 votes |
private LoggingConfigurationUpdater getOrCreateUpdater() { final LogContext logContext = LogContext.getLogContext(); final org.jboss.logmanager.Logger rootLogger = logContext.getLogger(""); LoggingConfigurationUpdater updater = rootLogger.getAttachment(KEY); if (updater == null) { final LogContextConfiguration logContextConfiguration = getOrCreateConfiguration(rootLogger); if (logContextConfiguration == null) { return null; } updater = new LoggingConfigurationUpdater(logContextConfiguration); final LoggingConfigurationUpdater appearing = rootLogger.attachIfAbsent(KEY, updater); if (appearing != null) { updater = appearing; } } return updater; }
Example 2
Source File: LogContextStdioContextSelector.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public StdioContext getStdioContext() { final LogContext logContext = LogContext.getLogContext(); final Logger root = logContext.getLogger(CommonAttributes.ROOT_LOGGER_NAME); StdioContext stdioContext = root.getAttachment(STDIO_CONTEXT_ATTACHMENT_KEY); if (stdioContext == null) { stdioContext = StdioContext.create( new NullInputStream(), new LoggingOutputStream(logContext.getLogger("stdout"), Level.INFO), new LoggingOutputStream(logContext.getLogger("stderr"), Level.ERROR) ); final StdioContext appearing = root.attachIfAbsent(STDIO_CONTEXT_ATTACHMENT_KEY, stdioContext); if (appearing != null) { stdioContext = appearing; } } return stdioContext; }
Example 3
Source File: LoggingOperations.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private static ConfigurationPersistence getConfigurationPersistence(final OperationContext context) { final PathAddress address = context.getCurrentAddress(); final LogContext logContext; if (LoggingProfileOperations.isLoggingProfileAddress(address)) { logContext = LoggingProfileContextSelector.getInstance().get(LoggingProfileOperations.getLoggingProfileName(address)); } else { logContext = LogContext.getLogContext(); } return ConfigurationPersistence.getConfigurationPersistence(logContext); }
Example 4
Source File: LoggingSubsystemRollbackTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public void rollbackAdd(final String profileName) throws Exception { // Save the current model final ModelNode validSubsystemModel = getSubsystemModel(kernelServices); // Add a handler to be removed final PathAddress consoleHandler = createConsoleHandlerAddress(profileName, "CONSOLE2"); // Create a new handler ModelNode op = SubsystemOperations.createAddOperation(consoleHandler.toModelNode()); op.get(CommonAttributes.LEVEL.getName()).set("INFO"); op.get(AbstractHandlerDefinition.FORMATTER.getName()).set("%d{HH:mm:ss,SSS} %-5p [%c] (%t) CONSOLE2: %s%e%n"); ModelNode result = kernelServices.executeOperation(op); Assert.assertFalse("The add operation should have failed, but was successful: " + result, SubsystemOperations.isSuccessfulOutcome(result)); // verify the subsystem model matches the old model ModelNode currentModel = getSubsystemModel(kernelServices); compare(profileName, validSubsystemModel, currentModel); final LogContext logContext = (profileName == null ? LogContext.getLogContext() : LoggingProfileContextSelector.getInstance().get(profileName)); ConfigurationPersistence config = ConfigurationPersistence.getConfigurationPersistence(logContext); compare(profileName, currentModel, config); // Fail on a logger write attribute final PathAddress loggerAddress = createLoggerAddress(profileName, "org.jboss.as.logging.test"); op = SubsystemOperations.createAddOperation(loggerAddress.toModelNode()); result = kernelServices.executeOperation(op); Assert.assertFalse("The add operation should have failed, but was successful: " + result, SubsystemOperations.isSuccessfulOutcome(result)); // verify the subsystem model matches the old model currentModel = getSubsystemModel(kernelServices); compare(profileName, validSubsystemModel, currentModel); config = ConfigurationPersistence.getConfigurationPersistence(logContext); compare(profileName, currentModel, config); }
Example 5
Source File: LoggingSubsystemRollbackTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public void rollbackWriteAttribute(final String profileName) throws Exception { // Save the current model final ModelNode validSubsystemModel = getSubsystemModel(kernelServices); // Add a handler to be removed final PathAddress consoleHandler = createConsoleHandlerAddress(profileName, "CONSOLE"); // Create a new handler ModelNode op = SubsystemOperations.createWriteAttributeOperation(consoleHandler.toModelNode(), ConsoleHandlerResourceDefinition.TARGET, "System.err"); ModelNode result = kernelServices.executeOperation(op); Assert.assertFalse("The write operation should have failed, but was successful: " + result, SubsystemOperations.isSuccessfulOutcome(result)); // verify the subsystem model matches the old model ModelNode currentModel = getSubsystemModel(kernelServices); compare(profileName, validSubsystemModel, currentModel); final LogContext logContext = (profileName == null ? LogContext.getLogContext() : LoggingProfileContextSelector.getInstance().get(profileName)); ConfigurationPersistence config = ConfigurationPersistence.getConfigurationPersistence(logContext); compare(profileName, currentModel, config); // Fail on a logger write attribute final PathAddress rootLoggerAddress = createRootLoggerAddress(profileName); op = SubsystemOperations.createWriteAttributeOperation(rootLoggerAddress.toModelNode(), CommonAttributes.LEVEL, "TRACE"); result = kernelServices.executeOperation(op); Assert.assertFalse("The write operation should have failed, but was successful: " + result, SubsystemOperations.isSuccessfulOutcome(result)); // verify the subsystem model matches the old model currentModel = getSubsystemModel(kernelServices); compare(profileName, validSubsystemModel, currentModel); config = ConfigurationPersistence.getConfigurationPersistence(logContext); compare(profileName, currentModel, config); }
Example 6
Source File: LoggingSubsystemRollbackTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public void rollbackUpdateAttribute(final String profileName) throws Exception { // Save the current model final ModelNode validSubsystemModel = getSubsystemModel(kernelServices); // Add a handler to be removed final PathAddress consoleHandler = createConsoleHandlerAddress(profileName, "CONSOLE"); // Create a new handler ModelNode op = SubsystemOperations.createOperation(AbstractHandlerDefinition.CHANGE_LEVEL_OPERATION_NAME, consoleHandler.toModelNode()); op.get(CommonAttributes.LEVEL.getName()).set("DEBUG"); ModelNode result = kernelServices.executeOperation(op); Assert.assertFalse("The update operation should have failed, but was successful: " + result, SubsystemOperations.isSuccessfulOutcome(result)); // verify the subsystem model matches the old model ModelNode currentModel = getSubsystemModel(kernelServices); compare(profileName, validSubsystemModel, currentModel); final LogContext logContext = (profileName == null ? LogContext.getLogContext() : LoggingProfileContextSelector.getInstance().get(profileName)); ConfigurationPersistence config = ConfigurationPersistence.getConfigurationPersistence(logContext); compare(profileName, currentModel, config); // Fail on a logger write attribute final PathAddress rootLoggerAddress = createRootLoggerAddress(profileName); op = SubsystemOperations.createOperation("change-root-log-level", rootLoggerAddress.toModelNode()); op.get(CommonAttributes.LEVEL.getName()).set("TRACE"); result = kernelServices.executeOperation(op); Assert.assertFalse("The update operation should have failed, but was successful: " + result, SubsystemOperations.isSuccessfulOutcome(result)); // verify the subsystem model matches the old model currentModel = getSubsystemModel(kernelServices); compare(profileName, validSubsystemModel, currentModel); config = ConfigurationPersistence.getConfigurationPersistence(logContext); compare(profileName, currentModel, config); }
Example 7
Source File: LoggingSubsystemRollbackTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public void rollbackRemove(final String profileName) throws Exception { // Save the current model final ModelNode validSubsystemModel = getSubsystemModel(kernelServices); final CompositeOperationBuilder compositeOperationBuilder = CompositeOperationBuilder.create(); // The handler address to remove final PathAddress consoleHandler = createConsoleHandlerAddress(profileName, "CONSOLE"); // Remove the handler compositeOperationBuilder.addStep(SubsystemOperations.createRemoveOperation(consoleHandler.toModelNode())); // The logger to remove final PathAddress loggerAddress = createLoggerAddress(profileName, "org.jboss.as.logging"); compositeOperationBuilder.addStep(SubsystemOperations.createRemoveOperation(loggerAddress.toModelNode())); // Add a step to fail final ModelNode rootLoggerAddress = createRootLoggerAddress(profileName).toModelNode(); compositeOperationBuilder.addStep(SubsystemOperations.createWriteAttributeOperation(rootLoggerAddress, CommonAttributes.LEVEL, "INFO")); ModelNode result = kernelServices.executeOperation(compositeOperationBuilder.build().getOperation()); Assert.assertFalse("The update operation should have failed, but was successful: " + result, SubsystemOperations.isSuccessfulOutcome(result)); // verify the subsystem model matches the old model ModelNode currentModel = getSubsystemModel(kernelServices); compare(profileName, validSubsystemModel, currentModel); final LogContext logContext = (profileName == null ? LogContext.getLogContext() : LoggingProfileContextSelector.getInstance().get(profileName)); ConfigurationPersistence config = ConfigurationPersistence.getConfigurationPersistence(logContext); compare(profileName, currentModel, config); }