當前位置: 首頁>>代碼示例>>Java>>正文


Java LogContext.getLogContext方法代碼示例

本文整理匯總了Java中org.jboss.logmanager.LogContext.getLogContext方法的典型用法代碼示例。如果您正苦於以下問題:Java LogContext.getLogContext方法的具體用法?Java LogContext.getLogContext怎麽用?Java LogContext.getLogContext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jboss.logmanager.LogContext的用法示例。


在下文中一共展示了LogContext.getLogContext方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getStdioContext

import org.jboss.logmanager.LogContext; //導入方法依賴的package包/類
@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;
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:19,代碼來源:LogContextStdioContextSelector.java

示例2: WildFlyLogContextSelectorImpl

import org.jboss.logmanager.LogContext; //導入方法依賴的package包/類
public WildFlyLogContextSelectorImpl() {
    counter = new AtomicInteger(0);
    // Use the current log context as the default, not LogContext.DEFAULT_LOG_CONTEXT_SELECTOR
    // This allows embedding use cases to control the log context
    final LogContext defaultLogContext = LogContext.getLogContext();
    contextSelector = new ClassLoaderLogContextSelector(new LogContextSelector() {
        @Override
        public LogContext getLogContext() {
            return defaultLogContext;
        }
    }, true);
    threadLocalContextSelector = new ThreadLocalLogContextSelector(contextSelector);
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:14,代碼來源:WildFlyLogContextSelectorImpl.java

示例3: rollbackAdd

import org.jboss.logmanager.LogContext; //導入方法依賴的package包/類
public void rollbackAdd(final String profileName) throws Exception {
    final KernelServices kernelServices = boot();

    // 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);
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:37,代碼來源:LoggingSubsystemRollbackTestCase.java

示例4: rollbackWriteAttribute

import org.jboss.logmanager.LogContext; //導入方法依賴的package包/類
public void rollbackWriteAttribute(final String profileName) throws Exception {
    final KernelServices kernelServices = boot();

    // 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);

}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:36,代碼來源:LoggingSubsystemRollbackTestCase.java

示例5: rollbackUpdateAttribute

import org.jboss.logmanager.LogContext; //導入方法依賴的package包/類
public void rollbackUpdateAttribute(final String profileName) throws Exception {
    final KernelServices kernelServices = boot();

    // 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(RootLoggerResourceDefinition.ROOT_LOGGER_CHANGE_LEVEL_OPERATION_NAME, 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);

}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:38,代碼來源:LoggingSubsystemRollbackTestCase.java

示例6: rollbackRemove

import org.jboss.logmanager.LogContext; //導入方法依賴的package包/類
public void rollbackRemove(final String profileName) throws Exception {
    final KernelServices kernelServices = boot();

    // 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);

}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:34,代碼來源:LoggingSubsystemRollbackTestCase.java


注:本文中的org.jboss.logmanager.LogContext.getLogContext方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。