当前位置: 首页>>代码示例>>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;未经允许,请勿转载。