Java Code Examples for org.jboss.modules.Module#setModuleLogger()

The following examples show how to use org.jboss.modules.Module#setModuleLogger() . 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: Container.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 6 votes vote down vote up
private void createServer(boolean debugBootstrap, URL xmlConfig) throws Exception {
    if (System.getProperty("boot.module.loader") == null) {
        System.setProperty("boot.module.loader", BootModuleLoader.class.getName());
    }
    if (debugBootstrap) {
        Module.setModuleLogger(new StreamModuleLogger(System.err));
    }
    Module module = Module.getBootModuleLoader().loadModule(ModuleIdentifier.create("org.wildfly.swarm.container", "runtime"));
    Class<?> serverClass = module.getClassLoader().loadClass("org.wildfly.swarm.container.runtime.RuntimeServer");
    try {
        this.server = (Server) serverClass.newInstance();
        if (this.xmlConfig != null)
            this.server.setXmlConfig(this.xmlConfig);
    } catch (Throwable t) {
        t.printStackTrace();
    }
}
 
Example 2
Source File: LoggerContext.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void activate() {
    final Module logModule;
    try {
        logModule = moduleLoader.loadModule(MODULE_ID_LOGGING);
    } catch (final ModuleLoadException mle) {
        throw EmbeddedLogger.ROOT_LOGGER.moduleLoaderError(mle, MODULE_ID_LOGGING, moduleLoader);
    }

    final ModuleClassLoader logModuleClassLoader = logModule.getClassLoader();
    final ClassLoader tccl = getTccl();
    try {
        setTccl(logModuleClassLoader);
        loggerToRestore = Module.getModuleLogger();
        Module.setModuleLogger(new JBossLoggingModuleLogger());
    } finally {
        // Reset TCCL
        setTccl(tccl);
    }
}
 
Example 3
Source File: LoggerContext.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void restore() {
    final Module logModule;
    try {
        logModule = moduleLoader.loadModule(MODULE_ID_LOGGING);
    } catch (final ModuleLoadException mle) {
        throw EmbeddedLogger.ROOT_LOGGER.moduleLoaderError(mle, MODULE_ID_LOGGING, moduleLoader);
    }

    final ModuleClassLoader logModuleClassLoader = logModule.getClassLoader();
    final ClassLoader tccl = getTccl();
    try {
        setTccl(logModuleClassLoader);
        final ModuleLogger loggerToRestore = this.loggerToRestore;
        if (loggerToRestore == null) {
            Module.setModuleLogger(NoopModuleLogger.getInstance());
        } else {
            Module.setModuleLogger(loggerToRestore);
        }
    } finally {
        // Reset TCCL
        setTccl(tccl);
    }
}
 
Example 4
Source File: Swarm.java    From thorntail with Apache License 2.0 4 votes vote down vote up
public Swarm(boolean debugBootstrap, Properties properties, Map<String, String> environment, String... args) throws Exception {
    if (System.getProperty(BOOT_MODULE_PROPERTY) == null) {
        System.setProperty(BOOT_MODULE_PROPERTY, BootModuleLoader.class.getName());
    }
    if (debugBootstrap) {
        Module.setModuleLogger(new StreamModuleLogger(System.err));
    }

    BootstrapUtil.convertSwarmSystemPropertiesToThorntail();

    setArgs(args);
    this.debugBootstrap = debugBootstrap;

    // Need to setup Logging here so that Weld doesn't default to JUL.
    try {
        Module loggingModule = Module.getBootModuleLoader().loadModule("org.wildfly.swarm.logging:runtime");

        ClassLoader originalCl = Thread.currentThread().getContextClassLoader();
        try {
            Thread.currentThread().setContextClassLoader(loggingModule.getClassLoader());
            System.setProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager");
            //force logging init
            LogManager.getLogManager();
            Class<?> logManagerClass = loggingModule.getClassLoader().loadClass("org.wildfly.swarm.container.runtime.logging.JBossLoggingManager");
            BootstrapLogger.setBackingLoggerManager((BackingLoggerManager) logManagerClass.newInstance());
        } finally {
            Thread.currentThread().setContextClassLoader(originalCl);
        }
    } catch (ModuleLoadException e) {
        System.err.println("[WARN] logging not available, logging will not be configured");
    }
    installModuleMBeanServer();
    createShrinkWrapDomain();

    this.commandLine = CommandLine.parse(args);
    this.configView = ConfigViewFactory.defaultFactory(properties, environment);

    if (ApplicationEnvironment.get().isHollow()) {
        if (!this.commandLine.extraArguments().isEmpty()) {
            URLClassLoader firstDeploymentCL = new URLClassLoader(new URL[]{
                    new File(this.commandLine.extraArguments().get(0)).toURI().toURL()
            });
            this.configView.addLocator(new ClassLoaderConfigLocator(firstDeploymentCL));
        }
    }

    this.commandLine.apply(this);

    initializeConfigView(properties);

    this.isConstructing = false;
}
 
Example 5
Source File: FurnaceImpl.java    From furnace with Eclipse Public License 1.0 4 votes vote down vote up
public Furnace enableLogging()
{
   assertNotAlive();
   Module.setModuleLogger(new StreamModuleLogger(System.err));
   return this;
}