Java Examples for org.slf4j.ILoggerFactory

The following java examples will help you to understand the usage of org.slf4j.ILoggerFactory. These source code samples are taken from different open source projects.

Example 1
Project: logback-master  File: StaticLoggerBinder.java View source code
public ILoggerFactory getLoggerFactory() {
    if (!initialized) {
        return defaultLoggerContext;
    }
    if (contextSelectorBinder.getContextSelector() == null) {
        throw new IllegalStateException("contextSelector cannot be null. See also " + NULL_CS_URL);
    }
    return contextSelectorBinder.getContextSelector().getLoggerContext();
}
Example 2
Project: appstatus-master  File: LogbackLoggersManager.java View source code
public List<LoggerConfig> getLoggers() {
    List<LoggerConfig> loggers = new ArrayList<LoggerConfig>();
    ILoggerFactory loggerFactory = LoggerFactory.getILoggerFactory();
    if (loggerFactory instanceof LoggerContext) {
        LoggerContext context = (LoggerContext) loggerFactory;
        for (ch.qos.logback.classic.Logger l : context.getLoggerList()) {
            loggers.add(new LoggerConfig(l.getName(), l.getEffectiveLevel().toString()));
        }
    }
    return loggers;
}
Example 3
Project: buckminster-master  File: ExtensionPointLoader.java View source code
private static void loadExtensions() {
    IConfigurationElement[] elems = Platform.getExtensionRegistry().getConfigurationElementsFor(SLF4J_IMPL_POINT);
    if (elems.length == 0)
        return;
    IConfigurationElement elem = elems[0];
    try {
        //$NON-NLS-1$
        s_loggerFactory = (ILoggerFactory) elem.createExecutableExtension("loggerFactory");
    } catch (CoreException e) {
    }
    try {
        //$NON-NLS-1$
        s_markerFactory = (IMarkerFactory) elem.createExecutableExtension("markerFactory");
    } catch (CoreException e) {
    }
    try {
        //$NON-NLS-1$
        s_mdcAdapter = (MDCAdapter) elem.createExecutableExtension("mdcAdapter");
    } catch (CoreException e) {
    }
}
Example 4
Project: log-queue-master  File: StaticLoggerBinderTest.java View source code
@Test
public void testGetLoggerFactory() {
    final ILoggerFactory loggerFactory1 = StaticLoggerBinder.getSingleton().getLoggerFactory();
    final ILoggerFactory loggerFactory2 = StaticLoggerBinder.getSingleton().getLoggerFactory();
    assertNotNull(loggerFactory1);
    assertTrue(loggerFactory1 == loggerFactory2);
    assertTrue(loggerFactory1 instanceof EgymLoggerFactory);
}
Example 5
Project: citrus-master  File: LogbackConfigurator.java View source code
private LoggerContext getLoggerContext(Map<String, String> props) {
    ILoggerFactory lcObject = LoggerFactory.getILoggerFactory();
    if (!(lcObject instanceof LoggerContext)) {
        throw new LogbackException("Expected LOGBACK binding with SLF4J, but another log system has taken the place: " + lcObject.getClass().getSimpleName());
    }
    LoggerContext lc = (LoggerContext) lcObject;
    lc.reset();
    for (Map.Entry<String, String> entry : props.entrySet()) {
        lc.putProperty(entry.getKey(), entry.getValue());
    }
    return lc;
}
Example 6
Project: citrus-tool-master  File: LogbackConfigurator.java View source code
private LoggerContext getLoggerContext(Map<String, String> props) {
    ILoggerFactory lcObject = LoggerFactory.getILoggerFactory();
    if (!(lcObject instanceof LoggerContext)) {
        throw new LogbackException("Expected LOGBACK binding with SLF4J, but another log system has taken the place: " + lcObject.getClass().getSimpleName());
    }
    LoggerContext lc = (LoggerContext) lcObject;
    lc.reset();
    for (Map.Entry<String, String> entry : props.entrySet()) {
        lc.putProperty(entry.getKey(), entry.getValue());
    }
    return lc;
}
Example 7
Project: deadcode4j-master  File: StaticLoggerBinder.java View source code
/**
     * Returns a <code>MavenPluginLoggerFactory</code> if the current thread was properly
     * {@link #setLog(org.apache.maven.plugin.logging.Log) initialized}; an instance of
     * <code>NOPLoggerFactory</code> otherwise.
     *
     * @since 1.5
     */
@Nonnull
@Override
public ILoggerFactory getLoggerFactory() {
    ILoggerFactory loggerFactory = loggerFactoryForThread.get();
    if (loggerFactory == null) {
        Util.report("No Maven Log set; using NOPLoggerFactory! " + "Make sure to call StaticLoggerBinder.getSingleton().setLog(Log log)!");
        loggerFactory = new NOPLoggerFactory();
    }
    return loggerFactory;
}
Example 8
Project: EMB-master  File: JRubyScriptingModule.java View source code
public ScriptingContainer get() {
    LocalContextScope scope = (useGlobalRubyRuntime ? LocalContextScope.SINGLETON : LocalContextScope.SINGLETHREAD);
    ScriptingContainer jruby = new ScriptingContainer(scope);
    if (gemHome != null) {
        // Overwrites GEM_HOME and GEM_PATH. GEM_PATH becomes same with GEM_HOME. Therefore
        // with this code, there're no ways to set extra GEM_PATHs in addition to GEM_HOME.
        // Here doesn't modify ENV['GEM_HOME'] so that a JVM process can create multiple
        // JRubyScriptingModule instances. However, because Gem loads ENV['GEM_HOME'] when
        // Gem.clear_paths is called, applications may use unexpected GEM_HOME if clear_path
        // is used.
        jruby.callMethod(jruby.runScriptlet("Gem"), "use_paths", gemHome, gemHome);
    }
    // load embulk.rb
    jruby.runScriptlet("require 'embulk'");
    // jruby searches embulk/java/bootstrap.rb from the beginning of $LOAD_PATH.
    jruby.runScriptlet("require 'embulk/java/bootstrap'");
    // TODO validate Embulk::Java::Injected::Injector doesn't exist? If it already exists,
    //      Injector is created more than once in this JVM although use_global_ruby_runtime
    //      is set to true.
    // set some constants
    jruby.callMethod(jruby.runScriptlet("Embulk::Java::Injected"), "const_set", "Injector", injector);
    jruby.callMethod(jruby.runScriptlet("Embulk::Java::Injected"), "const_set", "ModelManager", injector.getInstance(ModelManager.class));
    jruby.callMethod(jruby.runScriptlet("Embulk::Java::Injected"), "const_set", "BufferAllocator", injector.getInstance(BufferAllocator.class));
    // initialize logger
    jruby.callMethod(jruby.runScriptlet("Embulk"), "logger=", jruby.callMethod(jruby.runScriptlet("Embulk::Logger"), "new", injector.getInstance(ILoggerFactory.class).getLogger("ruby")));
    return jruby;
}
Example 9
Project: embulk-master  File: JRubyScriptingModule.java View source code
public ScriptingContainer get() {
    LocalContextScope scope = (useGlobalRubyRuntime ? LocalContextScope.SINGLETON : LocalContextScope.SINGLETHREAD);
    ScriptingContainer jruby = new ScriptingContainer(scope);
    if (gemHome != null) {
        // Overwrites GEM_HOME and GEM_PATH. GEM_PATH becomes same with GEM_HOME. Therefore
        // with this code, there're no ways to set extra GEM_PATHs in addition to GEM_HOME.
        // Here doesn't modify ENV['GEM_HOME'] so that a JVM process can create multiple
        // JRubyScriptingModule instances. However, because Gem loads ENV['GEM_HOME'] when
        // Gem.clear_paths is called, applications may use unexpected GEM_HOME if clear_path
        // is used.
        jruby.callMethod(jruby.runScriptlet("Gem"), "use_paths", gemHome, gemHome);
    }
    // load embulk.rb
    jruby.runScriptlet("require 'embulk'");
    // jruby searches embulk/java/bootstrap.rb from the beginning of $LOAD_PATH.
    jruby.runScriptlet("require 'embulk/java/bootstrap'");
    // TODO validate Embulk::Java::Injected::Injector doesn't exist? If it already exists,
    //      Injector is created more than once in this JVM although use_global_ruby_runtime
    //      is set to true.
    // set some constants
    jruby.callMethod(jruby.runScriptlet("Embulk::Java::Injected"), "const_set", "Injector", injector);
    jruby.callMethod(jruby.runScriptlet("Embulk::Java::Injected"), "const_set", "ModelManager", injector.getInstance(ModelManager.class));
    jruby.callMethod(jruby.runScriptlet("Embulk::Java::Injected"), "const_set", "BufferAllocator", injector.getInstance(BufferAllocator.class));
    // initialize logger
    jruby.callMethod(jruby.runScriptlet("Embulk"), "logger=", jruby.callMethod(jruby.runScriptlet("Embulk::Logger"), "new", injector.getInstance(ILoggerFactory.class).getLogger("ruby")));
    return jruby;
}
Example 10
Project: incubator-twill-master  File: ServiceMain.java View source code
protected final void doMain(final ZKClientService zkClientService, final Service service) throws ExecutionException, InterruptedException {
    configureLogger();
    final String serviceName = service.toString();
    Runtime.getRuntime().addShutdownHook(new Thread() {

        @Override
        public void run() {
            Services.chainStop(service, zkClientService);
        }
    });
    // Listener for state changes of the service
    ListenableFuture<Service.State> completion = Services.getCompletionFuture(service);
    try {
        try {
            // Starts the service
            LOG.info("Starting service {}.", serviceName);
            Futures.allAsList(Services.chainStart(zkClientService, service).get()).get();
            LOG.info("Service {} started.", serviceName);
        } catch (Throwable t) {
            LOG.error("Exception when starting service {}.", serviceName, t);
            System.exit(ContainerExitCodes.INIT_FAILED);
        }
        try {
            completion.get();
            LOG.info("Service {} completed.", serviceName);
        } catch (Throwable t) {
            LOG.error("Exception thrown from service {}.", serviceName, t);
            throw Throwables.propagate(t);
        }
    } finally {
        ILoggerFactory loggerFactory = LoggerFactory.getILoggerFactory();
        if (loggerFactory instanceof LoggerContext) {
            ((LoggerContext) loggerFactory).stop();
        }
    }
}
Example 11
Project: jubula.core-master  File: Configurator.java View source code
/**
     * @param logFileName
     *            the file name of the log which is getting created
     */
public static void loadLogbackConfiguration(String logFileName) {
    ILoggerFactory loggerFactory = LoggerFactory.getILoggerFactory();
    if (loggerFactory instanceof LoggerContext) {
        LoggerContext lc = (LoggerContext) loggerFactory;
        try {
            JoranConfigurator configurator = new JoranConfigurator();
            configurator.setContext(lc);
            // the context was probably already configured by default
            // configuration rules
            lc.reset();
            lc.setName(logFileName);
            InputStream is = Configurator.class.getResourceAsStream(//$NON-NLS-1$
            "configuration.xml");
            configurator.doConfigure(is);
        } catch (JoranException je) {
        }
        StatusPrinter.printInCaseOfErrorsOrWarnings(lc);
    }
}
Example 12
Project: parseq-master  File: TestCachedLoggerFactory.java View source code
@Test
public void testCaching() throws Exception {
    CountingLoggerFactory loggerFactory = new CountingLoggerFactory();
    final ILoggerFactory cachedFactory = new CachedLoggerFactory(loggerFactory);
    ExecutorService executorService = Executors.newFixedThreadPool(5);
    CountDownLatch startRace = new CountDownLatch(1);
    CountDownLatch stopRace = new CountDownLatch(5);
    for (int i = 0; i < 5; i++) {
        executorService.submit(() -> {
            try {
                startRace.await();
                cachedFactory.getLogger("com.linkedin.parseq.Task");
                stopRace.countDown();
            } catch (Exception e) {
                Assert.fail();
            }
        });
    }
    // start race
    startRace.countDown();
    assertTrue(stopRace.await(5000, TimeUnit.MILLISECONDS));
    Assert.assertEquals(loggerFactory.getCount(), 1);
}
Example 13
Project: rapidoid-master  File: LogbackUtil.java View source code
public static void setupLogger() {
    ILoggerFactory loggerFactory = LoggerFactory.getILoggerFactory();
    if (loggerFactory instanceof LoggerContext) {
        LoggerContext lc = (LoggerContext) loggerFactory;
        if (U.isEmpty(lc.getCopyOfPropertyMap())) {
            Logger root = lc.getLogger(Logger.ROOT_LOGGER_NAME);
            root.setLevel(Level.INFO);
        }
    }
}
Example 14
Project: xwiki-commons-master  File: LogBackUtilsTest.java View source code
@Test
public void getLoggerContextIsNullWhenLogbackNotPresent() {
    // Simulate that LogbackUtils.getLoggerFactory() returns a non LoggerContext instance.
    LogbackUtils utils = spy(new LogbackUtils());
    ILoggerFactory loggerFactory = mock(ILoggerFactory.class);
    when(utils.getLoggerFactory()).thenReturn(loggerFactory);
    Assert.assertNull(utils.getLoggerContext());
}
Example 15
Project: cdap-master  File: ServiceMain.java View source code
protected final void doMain(final Service mainService, Service... prerequisites) throws ExecutionException, InterruptedException {
    if (Boolean.parseBoolean(System.getProperty("twill.disable.kafka"))) {
        LOG.info("Log collection through kafka disabled");
    } else {
        configureLogger();
    }
    Service requiredServices = new CompositeService(prerequisites);
    Runtime.getRuntime().addShutdownHook(new Thread() {

        @Override
        public void run() {
            mainService.stopAndWait();
        }
    });
    // Listener for state changes of the service
    ListenableFuture<Service.State> completion = Services.getCompletionFuture(mainService);
    Throwable initFailure = null;
    try {
        try {
            // Starts the service
            LOG.info("Starting service {}.", mainService);
            Futures.allAsList(Services.chainStart(requiredServices, mainService).get()).get();
            LOG.info("Service {} started.", mainService);
        } catch (Throwable t) {
            LOG.error("Exception when starting service {}.", mainService, t);
            initFailure = t;
        }
        try {
            if (initFailure == null) {
                completion.get();
                LOG.info("Service {} completed.", mainService);
            }
        } catch (Throwable t) {
            LOG.error("Exception thrown from service {}.", mainService, t);
            throw Throwables.propagate(t);
        }
    } finally {
        requiredServices.stopAndWait();
        ILoggerFactory loggerFactory = LoggerFactory.getILoggerFactory();
        if (loggerFactory instanceof LoggerContext) {
            ((LoggerContext) loggerFactory).stop();
        }
        if (initFailure != null) {
            // Exit with the init fail exit code.
            System.exit(ContainerExitCodes.INIT_FAILED);
        }
    }
}
Example 16
Project: freelib-utils-master  File: LoggerFactory.java View source code
/**
     * Gets an {@link XMLResourceBundle} wrapped SLF4J {@link org.slf4j.Logger}.
     *
     * @param aName A class to use for the logger name
     * @param aBundleName The name of the resource bundle to use
     * @return A resource bundle aware logger
     */
public static final Logger getLogger(final String aName, final String aBundleName) {
    final ILoggerFactory factory = org.slf4j.LoggerFactory.getILoggerFactory();
    final Logger logger;
    if (aBundleName != null) {
        logger = new Logger(factory.getLogger(aName), aBundleName);
    } else {
        logger = new Logger(factory.getLogger(aName));
    }
    return logger;
}
Example 17
Project: Mav-master  File: MavenCli.java View source code
private PlexusContainer container(CliRequest cliRequest) throws Exception {
    if (cliRequest.classWorld == null) {
        cliRequest.classWorld = new ClassWorld("plexus.core", Thread.currentThread().getContextClassLoader());
    }
    ClassRealm coreRealm = cliRequest.classWorld.getClassRealm("plexus.core");
    if (coreRealm == null) {
        coreRealm = cliRequest.classWorld.getRealms().iterator().next();
    }
    List<File> extClassPath = parseExtClasspath(cliRequest);
    CoreExtensionEntry coreEntry = CoreExtensionEntry.discoverFrom(coreRealm);
    List<CoreExtensionEntry> extensions = loadCoreExtensions(cliRequest, coreRealm, coreEntry.getExportedArtifacts());
    ClassRealm containerRealm = setupContainerRealm(cliRequest.classWorld, coreRealm, extClassPath, extensions);
    ContainerConfiguration cc = new DefaultContainerConfiguration().setClassWorld(cliRequest.classWorld).setRealm(containerRealm).setClassPathScanning(PlexusConstants.SCANNING_INDEX).setAutoWiring(true).setName("maven");
    Set<String> exportedArtifacts = new HashSet<>(coreEntry.getExportedArtifacts());
    Set<String> exportedPackages = new HashSet<>(coreEntry.getExportedPackages());
    for (CoreExtensionEntry extension : extensions) {
        exportedArtifacts.addAll(extension.getExportedArtifacts());
        exportedPackages.addAll(extension.getExportedPackages());
    }
    final CoreExports exports = new CoreExports(containerRealm, exportedArtifacts, exportedPackages);
    DefaultPlexusContainer container = new DefaultPlexusContainer(cc, new AbstractModule() {

        @Override
        protected void configure() {
            bind(ILoggerFactory.class).toInstance(slf4jLoggerFactory);
            bind(CoreExports.class).toInstance(exports);
        }
    });
    // NOTE: To avoid inconsistencies, we'll use the TCCL exclusively for lookups
    container.setLookupRealm(null);
    Thread.currentThread().setContextClassLoader(container.getContainerRealm());
    container.setLoggerManager(plexusLoggerManager);
    for (CoreExtensionEntry extension : extensions) {
        container.discoverComponents(extension.getClassRealm(), new SessionScopeModule(container), new MojoExecutionScopeModule(container));
    }
    customizeContainer(container);
    container.getLoggerManager().setThresholds(cliRequest.request.getLoggingLevel());
    eventSpyDispatcher = container.lookup(EventSpyDispatcher.class);
    DefaultEventSpyContext eventSpyContext = new DefaultEventSpyContext();
    Map<String, Object> data = eventSpyContext.getData();
    data.put("plexus", container);
    data.put("workingDirectory", cliRequest.workingDirectory);
    data.put("systemProperties", cliRequest.systemProperties);
    data.put("userProperties", cliRequest.userProperties);
    data.put("versionProperties", CLIReportingUtils.getBuildProperties());
    eventSpyDispatcher.init(eventSpyContext);
    // refresh logger in case container got customized by spy
    slf4jLogger = slf4jLoggerFactory.getLogger(this.getClass().getName());
    maven = container.lookup(Maven.class);
    executionRequestPopulator = container.lookup(MavenExecutionRequestPopulator.class);
    modelProcessor = createModelProcessor(container);
    configurationProcessors = container.lookupMap(ConfigurationProcessor.class);
    toolchainsBuilder = container.lookup(ToolchainsBuilder.class);
    dispatcher = (DefaultSecDispatcher) container.lookup(SecDispatcher.class, "maven");
    return container;
}
Example 18
Project: maven-master  File: MavenCli.java View source code
private PlexusContainer container(CliRequest cliRequest) throws Exception {
    if (cliRequest.classWorld == null) {
        cliRequest.classWorld = new ClassWorld("plexus.core", Thread.currentThread().getContextClassLoader());
    }
    ClassRealm coreRealm = cliRequest.classWorld.getClassRealm("plexus.core");
    if (coreRealm == null) {
        coreRealm = cliRequest.classWorld.getRealms().iterator().next();
    }
    List<File> extClassPath = parseExtClasspath(cliRequest);
    CoreExtensionEntry coreEntry = CoreExtensionEntry.discoverFrom(coreRealm);
    List<CoreExtensionEntry> extensions = loadCoreExtensions(cliRequest, coreRealm, coreEntry.getExportedArtifacts());
    ClassRealm containerRealm = setupContainerRealm(cliRequest.classWorld, coreRealm, extClassPath, extensions);
    ContainerConfiguration cc = new DefaultContainerConfiguration().setClassWorld(cliRequest.classWorld).setRealm(containerRealm).setClassPathScanning(PlexusConstants.SCANNING_INDEX).setAutoWiring(true).setName("maven");
    Set<String> exportedArtifacts = new HashSet<>(coreEntry.getExportedArtifacts());
    Set<String> exportedPackages = new HashSet<>(coreEntry.getExportedPackages());
    for (CoreExtensionEntry extension : extensions) {
        exportedArtifacts.addAll(extension.getExportedArtifacts());
        exportedPackages.addAll(extension.getExportedPackages());
    }
    final CoreExports exports = new CoreExports(containerRealm, exportedArtifacts, exportedPackages);
    DefaultPlexusContainer container = new DefaultPlexusContainer(cc, new AbstractModule() {

        @Override
        protected void configure() {
            bind(ILoggerFactory.class).toInstance(slf4jLoggerFactory);
            bind(CoreExports.class).toInstance(exports);
        }
    });
    // NOTE: To avoid inconsistencies, we'll use the TCCL exclusively for lookups
    container.setLookupRealm(null);
    Thread.currentThread().setContextClassLoader(container.getContainerRealm());
    container.setLoggerManager(plexusLoggerManager);
    for (CoreExtensionEntry extension : extensions) {
        container.discoverComponents(extension.getClassRealm(), new SessionScopeModule(container), new MojoExecutionScopeModule(container));
    }
    customizeContainer(container);
    container.getLoggerManager().setThresholds(cliRequest.request.getLoggingLevel());
    eventSpyDispatcher = container.lookup(EventSpyDispatcher.class);
    DefaultEventSpyContext eventSpyContext = new DefaultEventSpyContext();
    Map<String, Object> data = eventSpyContext.getData();
    data.put("plexus", container);
    data.put("workingDirectory", cliRequest.workingDirectory);
    data.put("systemProperties", cliRequest.systemProperties);
    data.put("userProperties", cliRequest.userProperties);
    data.put("versionProperties", CLIReportingUtils.getBuildProperties());
    eventSpyDispatcher.init(eventSpyContext);
    // refresh logger in case container got customized by spy
    slf4jLogger = slf4jLoggerFactory.getLogger(this.getClass().getName());
    maven = container.lookup(Maven.class);
    executionRequestPopulator = container.lookup(MavenExecutionRequestPopulator.class);
    modelProcessor = createModelProcessor(container);
    configurationProcessors = container.lookupMap(ConfigurationProcessor.class);
    toolchainsBuilder = container.lookup(ToolchainsBuilder.class);
    dispatcher = (DefaultSecDispatcher) container.lookup(SecDispatcher.class, "maven");
    return container;
}
Example 19
Project: restx-master  File: LogAdminResource.java View source code
@RolesAllowed(AdminModule.RESTX_ADMIN_ROLE)
@GET("/@/loggers")
public Iterable<Logger> getLoggers() {
    ILoggerFactory loggerFactory = LoggerFactory.getILoggerFactory();
    if (loggerFactory instanceof LoggerContext) {
        LoggerContext context = (LoggerContext) loggerFactory;
        List<Logger> loggers = new ArrayList<>();
        for (ch.qos.logback.classic.Logger l : context.getLoggerList()) {
            loggers.add(new Logger(l.getName(), l.getEffectiveLevel().toString()));
        }
        return loggers;
    } else {
        return Collections.emptyList();
    }
}
Example 20
Project: sisu-guice-master  File: InjectorShell.java View source code
org.slf4j.ILoggerFactory loggerFactory() {
    if (loggerFactory == null) {
        try {
            loggerFactory = injector.getInstance(org.slf4j.ILoggerFactory.class);
        } catch (Throwable e) {
        }
        if (loggerFactory == null) {
            loggerFactory = org.slf4j.LoggerFactory.getILoggerFactory();
        }
    }
    return loggerFactory;
}
Example 21
Project: controller-master  File: LogbackConfigurationLoader.java View source code
/**
     * @return logback context
     */
private static LoggerContext getLoggerContext() {
    ILoggerFactory context = LoggerFactory.getILoggerFactory();
    if (context != null && context instanceof LoggerContext) {
        // now SLF4J is bound to logback in the current environment
        return (LoggerContext) context;
    }
    throw new IllegalStateException("current logger factory is not supported: " + context);
}
Example 22
Project: dropwizard-master  File: LoggingUtil.java View source code
/**
     * Acquires the logger context.
     * <p/>
     * <p>It tries to correctly acquire the logger context in the multi-threaded environment.
     * Because of the <a href="bug">http://jira.qos.ch/browse/SLF4J-167</a> a thread, that didn't
     * start initialization has a possibility to get a reference not to a real context, but to a
     * substitute.</p>
     * <p>To work around this bug we spin-loop the thread with a sensible timeout, while the
     * context is not initialized. We can't just make this method synchronized, because
     * {@code  LoggerFactory.getILoggerFactory} doesn't safely publish own state. Threads can
     * observe a stale state, even if the logger has been already initialized. That's why this
     * method is not thread-safe, but it makes the best effort to return the correct result in
     * the multi-threaded environment.</p>
     */
public static LoggerContext getLoggerContext() {
    final long startTime = System.nanoTime();
    while (true) {
        final ILoggerFactory iLoggerFactory = LoggerFactory.getILoggerFactory();
        if (iLoggerFactory instanceof LoggerContext) {
            return (LoggerContext) iLoggerFactory;
        }
        if ((System.nanoTime() - startTime) > LOGGER_CONTEXT_AWAITING_TIMEOUT.toNanoseconds()) {
            throw new IllegalStateException("Unable to acquire the logger context");
        }
        try {
            Thread.sleep(LOGGER_CONTEXT_AWAITING_SLEEP_TIME.toMilliseconds());
        } catch (InterruptedException e) {
            throw new IllegalStateException(e);
        }
    }
}
Example 23
Project: jetm-master  File: Slf4jAdapter.java View source code
public static boolean isConfigured() {
    // Make sure there is a binding on the class path
    try {
        Class.forName("org.slf4j.impl.StaticLoggerBinder");
    } catch (ClassNotFoundException e) {
        if (DEBUG) {
            System.err.println("JETM: No SLF4J binding found (" + e + ")");
        }
        return false;
    }
    if (DEBUG) {
        System.err.println("JETM: SLF4J binding OK");
    }
    // Also ensure we get a valid root logger
    ILoggerFactory lf = LoggerFactory.getILoggerFactory();
    Logger root = lf.getLogger(Logger.ROOT_LOGGER_NAME);
    if (DEBUG) {
        System.err.println("JETM: SLF4J root logger is " + root + " of type " + root.getClass().getCanonicalName());
    }
    return null != root;
}
Example 24
Project: logback-android-master  File: StaticLoggerBinder.java View source code
public ILoggerFactory getLoggerFactory() {
    if (!initialized) {
        return defaultLoggerContext;
    }
    if (contextSelectorBinder.getContextSelector() == null) {
        throw new IllegalStateException("contextSelector cannot be null. See also " + NULL_CS_URL);
    }
    return contextSelectorBinder.getContextSelector().getLoggerContext();
}
Example 25
Project: mojo-executor-master  File: MojoExecutorMojo.java View source code
private void disableLogging() throws MojoExecutionException {
    // Maven < 3.1
    Logger logger;
    try {
        logger = (Logger) FieldUtils.readField(getLog(), "logger", true);
    } catch (IllegalAccessException e) {
        throw new MojoExecutionException("Unable to access logger field ", e);
    }
    logger.setThreshold(5);
    // Maven >= 3.1
    ILoggerFactory slf4jLoggerFactory = LoggerFactory.getILoggerFactory();
    Slf4jConfiguration slf4jConfiguration = Slf4jConfigurationFactory.getConfiguration(slf4jLoggerFactory);
    slf4jConfiguration.setRootLoggerLevel(Slf4jConfiguration.Level.ERROR);
    slf4jConfiguration.activate();
}
Example 26
Project: mojo-master  File: MojoExecutorMojo.java View source code
private void disableLogging() throws MojoExecutionException {
    // Maven < 3.1
    Logger logger;
    try {
        logger = (Logger) FieldUtils.readField(getLog(), "logger", true);
    } catch (IllegalAccessException e) {
        throw new MojoExecutionException("Unable to access logger field ", e);
    }
    logger.setThreshold(5);
    // Maven >= 3.1
    ILoggerFactory slf4jLoggerFactory = LoggerFactory.getILoggerFactory();
    Slf4jConfiguration slf4jConfiguration = Slf4jConfigurationFactory.getConfiguration(slf4jLoggerFactory);
    slf4jConfiguration.setRootLoggerLevel(Slf4jConfiguration.Level.ERROR);
    slf4jConfiguration.activate();
}
Example 27
Project: molgenis-master  File: LogManagerController.java View source code
@RequestMapping(method = RequestMethod.GET)
public String init(Model model) {
    ILoggerFactory iLoggerFactory = LoggerFactory.getILoggerFactory();
    if (!(iLoggerFactory instanceof LoggerContext)) {
        throw new RuntimeException("Logger factory is not a Logback logger context");
    }
    LoggerContext loggerContext = (LoggerContext) iLoggerFactory;
    List<Logger> loggers = new ArrayList<Logger>();
    for (ch.qos.logback.classic.Logger logger : loggerContext.getLoggerList()) {
        if (logger.getLevel() != null || logger.iteratorForAppenders().hasNext()) {
            loggers.add(logger);
        }
    }
    model.addAttribute("loggers", loggers);
    model.addAttribute("levels", LOG_LEVELS);
    model.addAttribute("hasWritePermission", SecurityUtils.currentUserIsSu());
    return "view-logmanager";
}
Example 28
Project: ODL-master  File: Activator.java View source code
@Override
public void start(BundleContext context) {
    // Lets trigger the resolution of the slf4j logger factory
    ILoggerFactory f = LoggerFactory.getILoggerFactory();
    // Now retrieve a logger for the bridge
    log = f.getLogger("org.opendaylight.controller.logging.bridge.OSGI2SLF4J");
    if (this.log != null) {
        this.listener = new LogListenerImpl(log);
        ServiceReference service = null;
        service = context.getServiceReference(LogReaderService.class.getName());
        if (service != null) {
            LogReaderService reader = (LogReaderService) context.getService(service);
            if (reader == null) {
                this.log.error("Cannot register the LogListener because " + "cannot retrieve LogReaderService");
            }
            reader.addLogListener(this.listener);
            // Now lets walk all the exiting messages
            Enumeration<LogEntry> entries = reader.getLog();
            if (entries != null) {
                while (entries.hasMoreElements()) {
                    LogEntry entry = (LogEntry) entries.nextElement();
                    this.listener.logged(entry);
                }
            }
            /*
                 * Install the default exception handler so that the uncaught
                 * exceptions are handled by our customized handler. This new
                 * handler will display the exceptions to OSGI console as well
                 * as log to file.
                 */
            Thread.setDefaultUncaughtExceptionHandler(new org.opendaylight.controller.logging.bridge.internal.UncaughtExceptionHandler());
            /*
                 * Install the Shutdown handler. This will intercept SIGTERM signal and
                 * close the system bundle. This allows for a graceful  closing of OSGI
                 * framework.
                 */
            Runtime.getRuntime().addShutdownHook(new shutdownHandler(context));
        } else {
            this.log.error("Cannot register the LogListener because " + "cannot retrieve LogReaderService");
        }
    } else {
        System.err.println("Could not initialize the logging bridge subsytem");
    }
}
Example 29
Project: Pulsar-master  File: MessagingServiceShutdownHook.java View source code
public static void immediateFlushBufferedLogs() {
    ILoggerFactory loggerFactory = LoggerFactory.getILoggerFactory();
    if (loggerFactory.getClass().getName().equals(LogbackLoggerContextClassName)) {
        // Use reflection to force the flush on the logger
        try {
            Class<?> logbackLoggerContextClass = Class.forName(LogbackLoggerContextClassName);
            Method stop = logbackLoggerContextClass.getMethod("stop");
            stop.invoke(loggerFactory);
        } catch (Throwable t) {
            LOG.info("Failed to flush logs", t);
        }
    }
}
Example 30
Project: red5-master  File: StaticLoggerBinder.java View source code
public ILoggerFactory getLoggerFactory() {
    if (!initialized) {
        return defaultLoggerContext;
    }
    if (contextSelectorBinder.getContextSelector() == null) {
        throw new IllegalStateException("contextSelector cannot be null. See also " + NULL_CS_URL);
    }
    return contextSelectorBinder.getContextSelector().getLoggerContext();
}
Example 31
Project: red5-mobileconsole-master  File: StaticLoggerBinder.java View source code
public ILoggerFactory getLoggerFactory() {
    if (!initialized) {
        return defaultLoggerContext;
    }
    if (contextSelectorBinder.getContextSelector() == null) {
        throw new IllegalStateException("contextSelector cannot be null. See also " + NULL_CS_URL);
    }
    return contextSelectorBinder.getContextSelector().getLoggerContext();
}
Example 32
Project: RocketMQ-3.0.8-master  File: ClientLogger.java View source code
private static Logger createLogger(final String loggerName) {
    String logConfigFilePath = System.getProperty("rocketmq.client.log.configFile", System.getenv("ROCKETMQ_CLIENT_LOG_CONFIGFILE"));
    Boolean isloadconfig = Boolean.parseBoolean(System.getProperty("rocketmq.client.log.loadconfig", "true"));
    final String log4j_resource_file = System.getProperty("rocketmq.client.log4j.resource.fileName", "log4j_rocketmq_client.xml");
    final String logback_resource_file = System.getProperty("rocketmq.client.logback.resource.fileName", "logback_rocketmq_client.xml");
    if (isloadconfig) {
        try {
            ILoggerFactory iLoggerFactory = LoggerFactory.getILoggerFactory();
            Class classType = iLoggerFactory.getClass();
            if (classType.getName().equals("org.slf4j.impl.Log4jLoggerFactory")) {
                Class<?> DOMConfigurator = null;
                Object DOMConfiguratorObj = null;
                DOMConfigurator = Class.forName("org.apache.log4j.xml.DOMConfigurator");
                DOMConfiguratorObj = DOMConfigurator.newInstance();
                if (null == logConfigFilePath) {
                    // 如果应用没有�置,则使用jar包内置�置
                    Method configure = DOMConfiguratorObj.getClass().getMethod("configure", URL.class);
                    URL url = ClientLogger.class.getClassLoader().getResource(log4j_resource_file);
                    configure.invoke(DOMConfiguratorObj, url);
                } else {
                    Method configure = DOMConfiguratorObj.getClass().getMethod("configure", String.class);
                    configure.invoke(DOMConfiguratorObj, logConfigFilePath);
                }
            } else if (classType.getName().equals("ch.qos.logback.classic.LoggerContext")) {
                Class<?> joranConfigurator = null;
                Class<?> context = Class.forName("ch.qos.logback.core.Context");
                Object joranConfiguratoroObj = null;
                joranConfigurator = Class.forName("ch.qos.logback.classic.joran.JoranConfigurator");
                joranConfiguratoroObj = joranConfigurator.newInstance();
                Method setContext = joranConfiguratoroObj.getClass().getMethod("setContext", context);
                setContext.invoke(joranConfiguratoroObj, iLoggerFactory);
                if (null == logConfigFilePath) {
                    // 如果应用没有�置,则使用jar包内置�置
                    URL url = ClientLogger.class.getClassLoader().getResource(logback_resource_file);
                    Method doConfigure = joranConfiguratoroObj.getClass().getMethod("doConfigure", URL.class);
                    doConfigure.invoke(joranConfiguratoroObj, url);
                } else {
                    Method doConfigure = joranConfiguratoroObj.getClass().getMethod("doConfigure", String.class);
                    doConfigure.invoke(joranConfiguratoroObj, logConfigFilePath);
                }
            }
        } catch (Exception e) {
            System.err.println(e);
        }
    }
    return LoggerFactory.getLogger(LoggerName.ClientLoggerName);
}
Example 33
Project: sisu.plexus-master  File: PlexusSpaceModule.java View source code
// ----------------------------------------------------------------------
// Public methods
// ----------------------------------------------------------------------
public void configure(final Binder binder) {
    final Context context = new ParameterizedContext();
    binder.bind(Context.class).toInstance(context);
    final Provider<?> slf4jLoggerFactoryProvider = space.deferLoadClass("org.slf4j.ILoggerFactory").asProvider();
    binder.requestInjection(slf4jLoggerFactoryProvider);
    binder.bind(PlexusBeanConverter.class).to(PlexusXmlBeanConverter.class);
    binder.bind(PlexusBeanLocator.class).to(DefaultPlexusBeanLocator.class);
    binder.bind(PlexusContainer.class).to(PseudoPlexusContainer.class);
    final BeanManager manager = delegate instanceof PlexusLifecycleManager ? delegate : new PlexusLifecycleManager(binder.getProvider(Context.class), binder.getProvider(LoggerManager.class), slf4jLoggerFactoryProvider, delegate);
    binder.bind(BeanManager.class).toInstance(manager);
    final List<PlexusBeanModule> beanModules = new ArrayList<PlexusBeanModule>();
    final Map<?, ?> variables = new ContextMapAdapter(context);
    beanModules.add(new PlexusXmlBeanModule(space, variables));
    beanModules.add(new PlexusAnnotatedBeanModule(space, variables, scanning));
    binder.install(new PlexusBindingModule(manager, beanModules));
}
Example 34
Project: web-framework-master  File: LoggingUtil.java View source code
/**
     * Acquires the logger context.
     * <p/>
     * <p>It tries to correctly acquire the logger context in the multi-threaded environment.
     * Because of the <a href="bug">http://jira.qos.ch/browse/SLF4J-167</a> a thread, that didn't
     * start initialization has a possibility to get a reference not to a real context, but to a
     * substitute.</p>
     * <p>To work around this bug we spin-loop the thread with a sensible timeout, while the
     * context is not initialized. We can't just make this method synchronized, because
     * {@code  LoggerFactory.getILoggerFactory} doesn't safely publish own state. Threads can
     * observe a stale state, even if the logger has been already initialized. That's why this
     * method is not thread-safe, but it makes the best effort to return the correct result in
     * the multi-threaded environment.</p>
     */
public static LoggerContext getLoggerContext() {
    final long startTime = System.nanoTime();
    while (true) {
        final ILoggerFactory iLoggerFactory = LoggerFactory.getILoggerFactory();
        if (iLoggerFactory instanceof LoggerContext) {
            return (LoggerContext) iLoggerFactory;
        }
        if ((System.nanoTime() - startTime) > LOGGER_CONTEXT_AWAITING_TIMEOUT.toNanoseconds()) {
            throw new IllegalStateException("Unable to acquire the logger context");
        }
        try {
            Thread.sleep(LOGGER_CONTEXT_AWAITING_SLEEP_TIME.toMilliseconds());
        } catch (InterruptedException e) {
            throw new IllegalStateException(e);
        }
    }
}
Example 35
Project: buck-master  File: AetherUtil.java View source code
public static ServiceLocator initServiceLocator() {
    DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
    locator.setErrorHandler(new DefaultServiceLocator.ErrorHandler() {

        @Override
        public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception) {
            throw new RuntimeException(String.format("Failed to initialize service %s, implemented by %s: %s", type.getName(), impl.getName(), exception.getMessage()), exception);
        }
    });
    locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
    locator.addService(TransporterFactory.class, HttpTransporterFactory.class);
    locator.addService(TransporterFactory.class, FileTransporterFactory.class);
    // Use a no-op logger. Leaving this out would introduce a runtime dependency on log4j
    locator.addService(ILoggerFactory.class, NOPLoggerFactory.class);
    //    locator.addService(ILoggerFactory.class, Log4jLoggerFactory.class);
    return locator;
}
Example 36
Project: incubator-rocketmq-master  File: ClientLogger.java View source code
private static Logger createLogger(final String loggerName) {
    String logConfigFilePath = System.getProperty("rocketmq.client.log.configFile", System.getenv("ROCKETMQ_CLIENT_LOG_CONFIGFILE"));
    Boolean isloadconfig = Boolean.parseBoolean(System.getProperty("rocketmq.client.log.loadconfig", "true"));
    final String log4JResourceFile = System.getProperty("rocketmq.client.log4j.resource.fileName", "log4j_rocketmq_client.xml");
    final String logbackResourceFile = System.getProperty("rocketmq.client.logback.resource.fileName", "logback_rocketmq_client.xml");
    String clientLogRoot = System.getProperty(CLIENT_LOG_ROOT, "${user.home}/logs/rocketmqlogs");
    System.setProperty("client.logRoot", clientLogRoot);
    String clientLogLevel = System.getProperty(CLIENT_LOG_LEVEL, "INFO");
    System.setProperty("client.logLevel", clientLogLevel);
    String clientLogMaxIndex = System.getProperty(CLIENT_LOG_MAXINDEX, "10");
    System.setProperty("client.logFileMaxIndex", clientLogMaxIndex);
    if (isloadconfig) {
        try {
            ILoggerFactory iLoggerFactory = LoggerFactory.getILoggerFactory();
            Class classType = iLoggerFactory.getClass();
            if (classType.getName().equals("org.slf4j.impl.Log4jLoggerFactory")) {
                Class<?> domconfigurator;
                Object domconfiguratorobj;
                domconfigurator = Class.forName("org.apache.log4j.xml.DOMConfigurator");
                domconfiguratorobj = domconfigurator.newInstance();
                if (null == logConfigFilePath) {
                    Method configure = domconfiguratorobj.getClass().getMethod("configure", URL.class);
                    URL url = ClientLogger.class.getClassLoader().getResource(log4JResourceFile);
                    configure.invoke(domconfiguratorobj, url);
                } else {
                    Method configure = domconfiguratorobj.getClass().getMethod("configure", String.class);
                    configure.invoke(domconfiguratorobj, logConfigFilePath);
                }
            } else if (classType.getName().equals("ch.qos.logback.classic.LoggerContext")) {
                Class<?> joranConfigurator;
                Class<?> context = Class.forName("ch.qos.logback.core.Context");
                Object joranConfiguratoroObj;
                joranConfigurator = Class.forName("ch.qos.logback.classic.joran.JoranConfigurator");
                joranConfiguratoroObj = joranConfigurator.newInstance();
                Method setContext = joranConfiguratoroObj.getClass().getMethod("setContext", context);
                setContext.invoke(joranConfiguratoroObj, iLoggerFactory);
                if (null == logConfigFilePath) {
                    URL url = ClientLogger.class.getClassLoader().getResource(logbackResourceFile);
                    Method doConfigure = joranConfiguratoroObj.getClass().getMethod("doConfigure", URL.class);
                    doConfigure.invoke(joranConfiguratoroObj, url);
                } else {
                    Method doConfigure = joranConfiguratoroObj.getClass().getMethod("doConfigure", String.class);
                    doConfigure.invoke(joranConfiguratoroObj, logConfigFilePath);
                }
            }
        } catch (Exception e) {
            System.err.println(e);
        }
    }
    return LoggerFactory.getLogger(LoggerName.CLIENT_LOGGER_NAME);
}
Example 37
Project: lilith-master  File: Lilith.java View source code
private static void initLogbackConfig(URL configUrl) {
    ILoggerFactory loggerFactory = LoggerFactory.getILoggerFactory();
    if (loggerFactory instanceof LoggerContext) {
        LoggerContext loggerContext = (LoggerContext) loggerFactory;
        StatusManager sm = loggerContext.getStatusManager();
        sm.clear();
        // reset previous configuration initially loaded from logback.groovy
        loggerContext.reset();
        if (configUrl.toString().endsWith(GROOVY_EXTENSION)) {
            // http://jira.qos.ch/browse/LOGBACK-1079
            GafferConfigurator configurator = new GafferConfigurator(loggerContext);
            try {
                configurator.run(configUrl);
                final Logger logger = LoggerFactory.getLogger(Lilith.class);
                if (logger.isDebugEnabled())
                    logger.debug("Configured logging with {}.", configUrl);
            } catch (RuntimeException ex) {
                sm.add(new ErrorStatus("Exception while configuring Logback!", configUrl, ex));
            }
        } else {
            JoranConfigurator configurator = new JoranConfigurator();
            configurator.setContext(loggerContext);
            try {
                configurator.doConfigure(configUrl);
                final Logger logger = LoggerFactory.getLogger(Lilith.class);
                if (logger.isDebugEnabled())
                    logger.debug("Configured logging with {}.", configUrl);
            } catch (JoranException ex) {
                sm.add(new ErrorStatus("Exception while configuring Logback!", configUrl, ex));
            }
        }
        int level = ContextHelper.getHighestLevel(loggerContext);
        long lastReset = ContextHelper.getTimeOfLastReset(loggerContext);
        if (level > Status.INFO) {
            List<Status> statusList = StatusUtil.filterStatusListByTimeThreshold(sm.getCopyOfStatusList(), lastReset);
            if (statusList != null) {
                System.err.println("############################################################");
                System.err.println("## Logback Status                                         ##");
                System.err.println("############################################################");
                StringBuilder statusBuilder = new StringBuilder();
                for (Status current : statusList) {
                    appendStatus(statusBuilder, current, 0);
                }
                System.err.println(statusBuilder.toString());
                System.err.println("############################################################");
            }
        }
    }
}
Example 38
Project: m2e-core-master  File: MavenImpl.java View source code
private static DefaultPlexusContainer newPlexusContainer() throws PlexusContainerException {
    final ClassWorld classWorld = new ClassWorld(MAVEN_CORE_REALM_ID, ClassWorld.class.getClassLoader());
    final ClassRealm realm;
    try {
        realm = classWorld.getRealm(MAVEN_CORE_REALM_ID);
    } catch (NoSuchRealmException e) {
        throw new PlexusContainerException("Could not lookup required class realm", e);
    }
    final ContainerConfiguration mavenCoreCC = //
    new DefaultContainerConfiguration().setClassWorld(//
    classWorld).setRealm(//
    realm).setClassPathScanning(//
    PlexusConstants.SCANNING_INDEX).setAutoWiring(//
    true).setName(//$NON-NLS-1$
    "mavenCore");
    final Module logginModule = new AbstractModule() {

        protected void configure() {
            bind(ILoggerFactory.class).toInstance(LoggerFactory.getILoggerFactory());
        }
    };
    final Module coreExportsModule = new AbstractModule() {

        protected void configure() {
            ClassRealm realm = mavenCoreCC.getRealm();
            CoreExtensionEntry entry = CoreExtensionEntry.discoverFrom(realm);
            CoreExports exports = new CoreExports(entry);
            bind(CoreExports.class).toInstance(exports);
        }
    };
    return new DefaultPlexusContainer(mavenCoreCC, logginModule, new ExtensionModule(), coreExportsModule);
}
Example 39
Project: platform_build-master  File: AetherUtil.java View source code
public static ServiceLocator initServiceLocator() {
    DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
    locator.setErrorHandler(new DefaultServiceLocator.ErrorHandler() {

        @Override
        public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception) {
            throw new RuntimeException(String.format("Failed to initialize service %s, implemented by %s: %s", type.getName(), impl.getName(), exception.getMessage()), exception);
        }
    });
    locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
    locator.addService(TransporterFactory.class, HttpTransporterFactory.class);
    locator.addService(TransporterFactory.class, FileTransporterFactory.class);
    // Use a no-op logger. Leaving this out would introduce a runtime dependency on log4j
    locator.addService(ILoggerFactory.class, NOPLoggerFactory.class);
    //    locator.addService(ILoggerFactory.class, Log4jLoggerFactory.class);
    return locator;
}
Example 40
Project: Singularity-master  File: SingularityAbort.java View source code
private void flushLogs() {
    final long millisToWait = 100;
    LOG.info("Attempting to flush logs and wait {} ...", JavaUtils.durationFromMillis(millisToWait));
    ILoggerFactory loggerFactory = LoggerFactory.getILoggerFactory();
    if (loggerFactory instanceof LoggerContext) {
        LoggerContext context = (LoggerContext) loggerFactory;
        context.stop();
    }
    try {
        Thread.sleep(millisToWait);
    } catch (Exception e) {
        LOG.info("While sleeping for log flush", e);
    }
}
Example 41
Project: UniversalMediaServer-master  File: PMS.java View source code
@Override
public void run() {
    try {
        for (ExternalListener l : ExternalFactory.getExternalListeners()) {
            l.shutdown();
        }
        UPNPHelper.shutDownListener();
        UPNPHelper.sendByeBye();
        LOGGER.debug("Forcing shutdown of all active processes");
        for (Process p : currentProcesses) {
            try {
                p.exitValue();
            } catch (IllegalThreadStateException ise) {
                LOGGER.trace("Forcing shutdown of process: " + p);
                ProcessUtil.destroy(p);
            }
        }
        get().getServer().stop();
        Thread.sleep(500);
    } catch (InterruptedException e) {
        LOGGER.debug("Caught exception", e);
    }
    LOGGER.info("Stopping " + PropertiesUtil.getProjectProperties().get("project.name") + " " + getVersion());
    /**
				 * Stopping logging gracefully (flushing logs)
				 * No logging is available after this point
				 */
    ILoggerFactory iLoggerContext = LoggerFactory.getILoggerFactory();
    if (iLoggerContext instanceof LoggerContext) {
        ((LoggerContext) iLoggerContext).stop();
    } else {
        LOGGER.error("Unable to shut down logging gracefully");
    }
}
Example 42
Project: cache2k-master  File: Log.java View source code
/**
   * Finds a logger we can use. First we start with looking for a registered
   * service provider. Then apache commons logging. As a fallback we use JDK logging.
   */
private static void initializeLogFactory() {
    ServiceLoader<LogFactory> loader = ServiceLoader.load(LogFactory.class);
    for (LogFactory lf : loader) {
        logFactory = lf;
        log("New instance, using: " + logFactory.getClass().getName());
        return;
    }
    try {
        final org.slf4j.ILoggerFactory lf = org.slf4j.LoggerFactory.getILoggerFactory();
        if (!(lf instanceof NOPLoggerFactory)) {
            logFactory = new LogFactory() {

                @Override
                public Log getLog(String s) {
                    return new Slf4jLogger(lf.getLogger(s));
                }
            };
            log("New instance, using SLF4J logging");
            return;
        }
    } catch (NoClassDefFoundError ignore) {
    }
    try {
        final org.apache.commons.logging.LogFactory cl = org.apache.commons.logging.LogFactory.getFactory();
        logFactory = new LogFactory() {

            @Override
            public Log getLog(String s) {
                return new CommonsLogger(cl.getInstance(s));
            }
        };
        log("New instance, using commons logging");
        return;
    } catch (NoClassDefFoundError ignore) {
    }
    logFactory = new LogFactory() {

        @Override
        public Log getLog(String s) {
            return new JdkLogger(Logger.getLogger(s));
        }
    };
    log("New instance, using JDK logging");
}
Example 43
Project: cougar-master  File: HttpRequestLoggerTest.java View source code
@Before
public void init() throws Exception {
    TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
    request = mock(HttpServletRequest.class);
    response = mock(HttpServletResponse.class);
    registry = new EventLoggingRegistry();
    EventLogDefinition eld = new EventLogDefinition();
    eld.setRegistry(registry);
    eld.setLogName("ACCESS-LOG");
    eld.register();
    loggerFactory = mock(ILoggerFactory.class);
    oldLoggerFactory = HttpRequestLogger.setLoggerFactory(loggerFactory);
    eventLog = mock(Logger.class);
}
Example 44
Project: gemini.web.gemini-web-container-master  File: WebBundleScannerTests.java View source code
private void setExpectationsIncludingNestedJars(WebBundleScannerCallback callback) {
    setExpectations(callback);
    callback.classFound("org/slf4j/ILoggerFactory.class");
    callback.classFound("org/slf4j/IMarkerFactory.class");
    callback.classFound("org/slf4j/Logger.class");
    callback.classFound("org/slf4j/LoggerFactory.class");
    callback.classFound("org/slf4j/Marker.class");
    callback.classFound("org/slf4j/MarkerFactory.class");
    callback.classFound("org/slf4j/MDC.class");
    callback.classFound("org/slf4j/helpers/BasicMarker.class");
    callback.classFound("org/slf4j/helpers/BasicMarkerFactory.class");
    callback.classFound("org/slf4j/helpers/BasicMDCAdapter.class");
    callback.classFound("org/slf4j/helpers/FormattingTuple.class");
    callback.classFound("org/slf4j/helpers/MarkerIgnoringBase.class");
    callback.classFound("org/slf4j/helpers/MessageFormatter.class");
    callback.classFound("org/slf4j/helpers/NamedLoggerBase.class");
    callback.classFound("org/slf4j/helpers/NOPLogger.class");
    callback.classFound("org/slf4j/helpers/NOPLoggerFactory.class");
    callback.classFound("org/slf4j/helpers/NOPMDCAdapter.class");
    callback.classFound("org/slf4j/helpers/SubstituteLoggerFactory.class");
    callback.classFound("org/slf4j/helpers/Util.class");
    callback.classFound("org/slf4j/spi/LocationAwareLogger.class");
    callback.classFound("org/slf4j/spi/LoggerFactoryBinder.class");
    callback.classFound("org/slf4j/spi/MarkerFactoryBinder.class");
    callback.classFound("org/slf4j/spi/MDCAdapter.class");
}
Example 45
Project: logstash-logback-encoder-master  File: StructuredArguments.java View source code
/**
     * Format the argument into a string.
     * <p>
     * This method mimics the slf4j behaviour:
     * array objects are formatted as array using {@link Arrays#toString},
     * non array object using {@link String#valueOf}.
     * <p>
     *
     * @see org.slf4j.helpers.MessageFormatter#deeplyAppendParameter(StringBuilder, Object, Map)}.
     */
public static String toString(Object arg) {
    if (arg == null) {
        return "null";
    }
    Class argClass = arg.getClass();
    try {
        if (!argClass.isArray()) {
            return String.valueOf(arg);
        } else {
            if (argClass == byte[].class) {
                return Arrays.toString((byte[]) arg);
            } else if (argClass == short[].class) {
                return Arrays.toString((short[]) arg);
            } else if (argClass == int[].class) {
                return Arrays.toString((int[]) arg);
            } else if (argClass == long[].class) {
                return Arrays.toString((long[]) arg);
            } else if (argClass == char[].class) {
                return Arrays.toString((char[]) arg);
            } else if (argClass == float[].class) {
                return Arrays.toString((float[]) arg);
            } else if (argClass == double[].class) {
                return Arrays.toString((double[]) arg);
            } else if (argClass == boolean[].class) {
                return Arrays.toString((boolean[]) arg);
            } else {
                return Arrays.deepToString((Object[]) arg);
            }
        }
    } catch (Exception e) {
        ILoggerFactory loggerFactory = LoggerFactory.getILoggerFactory();
        if (loggerFactory instanceof Context) {
            Context context = (Context) loggerFactory;
            StatusManager statusManager = context.getStatusManager();
            statusManager.add(new WarnStatus("Failed toString() invocation on an object of type [" + argClass.getName() + "]", StructuredArguments.class, e));
        } else {
            System.err.println("Failed toString() invocation on an object of type [" + argClass.getName() + "]");
            e.printStackTrace();
        }
        return "[FAILED toString()]";
    }
}
Example 46
Project: ps3mediaserver-master  File: LoggingConfigFileLoader.java View source code
/**
	 * Loads the (optional) Logback configuration file.
	 *
	 * <p>
	 * It loads the file defined in the {@code project.logback} property
	 * (use {@code [PROFILE_DIR]} to specify profile folder) and (re-)initializes Logback with this file.
	 * </p>
	 *
	 * <p>
	 * If failed (file not found or unreadable) it tries to load {@code logback.xml} from the current directory.
	 * </p>
	 *
	 * <p>
	 * If running headless, then the alternative config file defined in {@code project.logback.headless} is tried.
	 * </p>
	 *
	 * <p>
	 * If no config file worked, then nothing is loaded and
	 * Logback will use the {@code logback.xml} file on the classpath as a default. If
	 * this doesn't exist then a basic console appender is used as fallback.
	 * </p>
	 *
	 * <strong>Note:</strong> Any error messages generated while parsing the
	 * config file are dumped only to {@code stdout}.
	 */
public static void load() {
    // Note: Do not use any logging method in this method!
    // Any status output needs to go to the console.
    File logFile = null;
    if (PMS.isHeadless()) {
        final String logFilePath = replace(PropertiesUtil.getProjectProperties().get("project.logback.headless"), "[PROFILE_DIR]", configuration.getProfileDirectory());
        if (isNotBlank(logFilePath)) {
            logFile = new File(logFilePath);
        }
    } else {
        final String logFilePath = replace(PropertiesUtil.getProjectProperties().get("project.logback"), "[PROFILE_DIR]", configuration.getProfileDirectory());
        if (isNotBlank(logFilePath)) {
            logFile = new File(logFilePath);
        }
    }
    if (logFile == null || !logFile.canRead()) {
        // Now try configs from the app folder.
        if (PMS.isHeadless()) {
            logFile = new File("logback.headless.xml");
        } else {
            logFile = new File("logback.xml");
        }
    }
    if (!logFile.canRead()) {
        // No problem, the internal logback.xml is used.
        return;
    }
    // Now get logback to actually use the config file
    ILoggerFactory ilf = LoggerFactory.getILoggerFactory();
    if (!(ilf instanceof LoggerContext)) {
        // Can't configure the logger, so just exit
        return;
    }
    LoggerContext lc = (LoggerContext) ilf;
    try {
        JoranConfigurator configurator = new JoranConfigurator();
        configurator.setContext(lc);
        // the context was probably already configured by
        // default configuration rules
        lc.reset();
        configurator.doConfigure(logFile);
        // Save the filepath after loading the file
        filepath = logFile.getAbsolutePath();
    } catch (JoranException je) {
        je.printStackTrace();
    }
    for (Logger logger : lc.getLoggerList()) {
        Iterator<Appender<ILoggingEvent>> it = logger.iteratorForAppenders();
        while (it.hasNext()) {
            Appender<ILoggingEvent> ap = it.next();
            if (ap instanceof FileAppender) {
                FileAppender<ILoggingEvent> fa = (FileAppender<ILoggingEvent>) ap;
                logFilePaths.put(fa.getName(), fa.getFile());
            }
        }
    }
    StatusPrinter.printInCaseOfErrorsOrWarnings(lc);
}
Example 47
Project: spring-boot-master  File: LogbackLoggingSystemTests.java View source code
@Test
public void testBasicConfigLocation() throws Exception {
    this.loggingSystem.beforeInitialize();
    ILoggerFactory factory = StaticLoggerBinder.getSingleton().getLoggerFactory();
    LoggerContext context = (LoggerContext) factory;
    Logger root = context.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
    assertThat(root.getAppender("CONSOLE")).isNotNull();
}
Example 48
Project: sulky-master  File: LoggingTestBase.java View source code
@SuppressWarnings({ "PMD.AvoidPrintStackTrace" })
public static void resetLogging(boolean verbose) {
    if (verbose) {
        System.out.println("### Resetting logging configuration.");
    }
    ILoggerFactory loggerFactory = LoggerFactory.getILoggerFactory();
    if (loggerFactory instanceof LoggerContext) {
        LoggerContext loggerContext = (LoggerContext) loggerFactory;
        // reset previous configuration initially loaded from logback.xml
        if (verbose) {
            System.out.println("\nAbout to reset logging system.");
        }
        loggerContext.reset();
        JoranConfigurator configurator = new JoranConfigurator();
        configurator.setContext(loggerContext);
        URL configUrl;
        configUrl = LoggingTestBase.class.getResource("/logback-test.xml");
        if (configUrl == null) {
            configUrl = LoggingTestBase.class.getResource("/logback.xml");
        }
        try {
            configurator.doConfigure(configUrl);
            if (verbose) {
                System.out.println("\nPrinting status of logging system:");
                StatusPrinter.print(loggerContext);
            }
        } catch (JoranException ex) {
            System.err.println("!!! Error configuring logging framework with '" + configUrl + "'!");
            ex.printStackTrace();
            StatusPrinter.print(loggerContext);
        }
    }
}
Example 49
Project: wisdom-master  File: ChameleonInstanceHolder.java View source code
/**
     * Fixes the Chameleon logging configuration to write the logs in the logs/wisdom.log file instead of chameleon.log
     * file.
     *
     * @param basedir the base directory of the chameleon
     */
public static void fixLoggingSystem(File basedir) {
    ILoggerFactory factory = LoggerFactory.getILoggerFactory();
    if (factory instanceof LoggerContext) {
        // We know that we are using logback from here.
        LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
        ch.qos.logback.classic.Logger logbackLogger = lc.getLogger(Logger.ROOT_LOGGER_NAME);
        if (logbackLogger == null) {
            return;
        }
        Iterator<Appender<ILoggingEvent>> iterator = logbackLogger.iteratorForAppenders();
        while (iterator.hasNext()) {
            Appender<ILoggingEvent> appender = iterator.next();
            if (appender instanceof AsyncAppender) {
                appender = ((AsyncAppender) appender).getAppender("FILE");
            }
            if (appender instanceof RollingFileAppender) {
                RollingFileAppender<ILoggingEvent> fileAppender = (RollingFileAppender<ILoggingEvent>) appender;
                String file = new File(basedir, "logs/wisdom.log").getAbsolutePath();
                fileAppender.stop();
                // Remove the created log directory.
                // We do that afterwards because on Windows the file cannot be deleted while we still have a logger
                // using it.
                FileUtils.deleteQuietly(new File("logs"));
                fileAppender.setFile(file);
                fileAppender.setContext(lc);
                fileAppender.start();
            }
        }
    }
}
Example 50
Project: wunderboss-master  File: WunderBoss.java View source code
private static void configureLogback() {
    ILoggerFactory loggerFactory = LoggerFactory.getILoggerFactory();
    ClassLoader cl = loggerFactory.getClass().getClassLoader();
    try {
        cl.loadClass("ch.qos.logback.classic.LoggerContext");
        LogbackUtil.configureLogback(loggerFactory);
    } catch (ClassNotFoundException ignored) {
    }
}
Example 51
Project: prim-ftpd-master  File: LoggerFactory.java View source code
/**
   * Return the {@link ILoggerFactory} instance in use.
   *
   * <p>
   * ILoggerFactory instance is bound with this class at compile time.
   *
   * @return the ILoggerFactory instance in use
   */
public static ILoggerFactory getILoggerFactory() {
    if (INITIALIZATION_STATE == UNINITIALIZED) {
        INITIALIZATION_STATE = ONGOING_INITILIZATION;
        performInitialization();
    }
    switch(INITIALIZATION_STATE) {
        case SUCCESSFUL_INITILIZATION:
            return PrimFtpdLoggerBinder.getSingleton().getLoggerFactory();
        case NOP_FALLBACK_INITILIZATION:
            return NOP_FALLBACK_FACTORY;
        case FAILED_INITILIZATION:
            throw new IllegalStateException(UNSUCCESSFUL_INIT_MSG);
        case ONGOING_INITILIZATION:
            // See also http://bugzilla.slf4j.org/show_bug.cgi?id=106
            return TEMP_FACTORY;
    }
    throw new IllegalStateException("Unreachable code");
}
Example 52
Project: airavata-master  File: ServerMain.java View source code
//	private static void addSecondaryShutdownHook(){
//		Runtime.getRuntime().addShutdownHook(new Thread(){
//			@Override
//			public void run() {
//				System.out.print("Graceful shutdown attempt is still active. Do you want to exit instead? (y/n)");
//				String command=System.console().readLine().trim().toLowerCase();
//				if (command.equals("yes") || command.equals("y")){
//					System.exit(1);
//				}
//			}
//		});
//	}
public static void main(String args[]) throws ParseException, IOException, AiravataException {
    ServerSettings.mergeSettingsCommandLineArgs(args);
    ServerSettings.setServerRoles(ApplicationSettings.getSetting(SERVERS_KEY, "all").split(","));
    if (ServerSettings.isEnabledKafkaLogging()) {
        final ILoggerFactory iLoggerFactory = LoggerFactory.getILoggerFactory();
        if (iLoggerFactory instanceof LoggerContext) {
            final KafkaAppender kafkaAppender = new KafkaAppender(ServerSettings.getKafkaBrokerList(), ServerSettings.getKafkaTopicPrefix());
            kafkaAppender.setContext((LoggerContext) iLoggerFactory);
            kafkaAppender.setName("kafka-appender");
            kafkaAppender.clearAllFilters();
            kafkaAppender.start();
            // Until AIRAVATA-2073 filter org.apache.kafka logs
            ((LoggerContext) iLoggerFactory).getLogger("org.apache.airavata").addAppender(kafkaAppender);
            ((LoggerContext) iLoggerFactory).getLogger("org.apache.zookeeper").addAppender(kafkaAppender);
            ((LoggerContext) iLoggerFactory).getLogger("org.apache.derby").addAppender(kafkaAppender);
            ((LoggerContext) iLoggerFactory).getLogger("org.apache.commons").addAppender(kafkaAppender);
            ((LoggerContext) iLoggerFactory).getLogger("org.apache.thrift").addAppender(kafkaAppender);
            ((LoggerContext) iLoggerFactory).getLogger("com").addAppender(kafkaAppender);
            ((LoggerContext) iLoggerFactory).getLogger("net").addAppender(kafkaAppender);
        } else {
            logger.warn("Kafka logging is enabled but cannot find logback LoggerContext, found", iLoggerFactory.getClass().toString());
            throw new AiravataException("Kafka logging is enabled but cannot find logback LoggerContext");
        }
    } else {
        logger.info("Kafka logging is disabled in airavata server configurations");
    }
    CommandLineParameters commandLineParameters = StringUtil.getCommandLineParser(args);
    if (commandLineParameters.getArguments().contains(STOP_COMMAND_STR)) {
        performServerStopRequest(commandLineParameters);
    } else {
        AiravataZKUtils.startEmbeddedZK(cnxnFactory);
        performServerStart(args);
    }
}
Example 53
Project: Baragon-master  File: LifecycleHelper.java View source code
private void flushLogs() {
    final long millisToWait = 100;
    ILoggerFactory loggerFactory = LoggerFactory.getILoggerFactory();
    if (loggerFactory instanceof LoggerContext) {
        LoggerContext context = (LoggerContext) loggerFactory;
        context.stop();
    }
    try {
        Thread.sleep(millisToWait);
    } catch (Exception e) {
        LOG.info("While sleeping for log flush", e);
    }
}
Example 54
Project: Repository-master  File: LogbackLogManager.java View source code
//
// Helpers
//
/**
   * Returns the current logger-context.
   */
@VisibleForTesting
static LoggerContext loggerContext() {
    ILoggerFactory factory = LoggerFactory.getILoggerFactory();
    if (factory instanceof LoggerContext) {
        return (LoggerContext) factory;
    }
    // we set org.ops4j.pax.logging.StaticLogbackContext=true in system.properties and access it statically
    return (LoggerContext) StaticLoggerBinder.getSingleton().getLoggerFactory();
}
Example 55
Project: ngrinder-master  File: GrinderProcess.java View source code
private LoggerContext configureLogging(final String workerName, final String logDirectory) throws EngineException {
    final ILoggerFactory iLoggerFactory = LoggerFactory.getILoggerFactory();
    if (iLoggerFactory instanceof Context) {
        final Context context = (Context) iLoggerFactory;
        final LoggerContext result = (LoggerContext) iLoggerFactory;
        final JoranConfigurator configurator = new JoranConfigurator();
        configurator.setContext(context);
        context.putProperty("WORKER_NAME", workerName);
        context.putProperty("LOG_DIRECTORY", logDirectory);
        try {
            configurator.doConfigure(GrinderProcess.class.getResource("/logback-worker.xml"));
        } catch (final JoranException e) {
            throw new EngineException("Could not initialise logger", e);
        }
        return result;
    } else {
        m_terminalLogger.warn("Logback not found; grinder log configuration will be ignored.\n" + "Consider adding logback-classic to the start of the CLASSPATH.");
        return null;
    }
}
Example 56
Project: oceano-master  File: MavenCli.java View source code
private PlexusContainer container(CliRequest cliRequest) throws Exception {
    if (cliRequest.classWorld == null) {
        cliRequest.classWorld = new ClassWorld("plexus.core", Thread.currentThread().getContextClassLoader());
    }
    DefaultPlexusContainer container = null;
    ContainerConfiguration cc = new DefaultContainerConfiguration().setClassWorld(cliRequest.classWorld).setRealm(setupContainerRealm(cliRequest)).setClassPathScanning(PlexusConstants.SCANNING_INDEX).setAutoWiring(true).setName("maven");
    container = new DefaultPlexusContainer(cc, new AbstractModule() {

        protected void configure() {
            bind(ILoggerFactory.class).toInstance(slf4jLoggerFactory);
        }
    });
    // NOTE: To avoid inconsistencies, we'll use the TCCL exclusively for lookups
    container.setLookupRealm(null);
    container.setLoggerManager(plexusLoggerManager);
    customizeContainer(container);
    container.getLoggerManager().setThresholds(cliRequest.request.getLoggingLevel());
    Thread.currentThread().setContextClassLoader(container.getContainerRealm());
    eventSpyDispatcher = container.lookup(EventSpyDispatcher.class);
    DefaultEventSpyContext eventSpyContext = new DefaultEventSpyContext();
    Map<String, Object> data = eventSpyContext.getData();
    data.put("plexus", container);
    data.put("workingDirectory", cliRequest.workingDirectory);
    data.put("systemProperties", cliRequest.systemProperties);
    data.put("userProperties", cliRequest.userProperties);
    data.put("versionProperties", CLIReportingUtils.getBuildProperties());
    eventSpyDispatcher.init(eventSpyContext);
    // refresh logger in case container got customized by spy
    slf4jLogger = slf4jLoggerFactory.getLogger(this.getClass().getName());
    maven = container.lookup(Maven.class);
    executionRequestPopulator = container.lookup(MavenExecutionRequestPopulator.class);
    modelProcessor = createModelProcessor(container);
    settingsBuilder = container.lookup(SettingsBuilder.class);
    dispatcher = (DefaultSecDispatcher) container.lookup(SecDispatcher.class, "maven");
    return container;
}
Example 57
Project: FireFly-master  File: StaticLoggerBinder.java View source code
@Override
public ILoggerFactory getLoggerFactory() {
    return loggerFactory;
}
Example 58
Project: core-ng-project-master  File: StaticLoggerBinder.java View source code
@Override
public ILoggerFactory getLoggerFactory() {
    return loggerFactory;
}
Example 59
Project: divconq-master  File: StaticLoggerBinder.java View source code
@Override
public ILoggerFactory getLoggerFactory() {
    return StaticLoggerBinder.instance;
}
Example 60
Project: jameica.webadmin-master  File: StaticLoggerBinder.java View source code
/**
	 * @see org.slf4j.spi.LoggerFactoryBinder#getLoggerFactory()
	 */
public ILoggerFactory getLoggerFactory() {
    return this.loggerFactory;
}
Example 61
Project: jPOS-master  File: StaticLoggerBinder.java View source code
public ILoggerFactory getLoggerFactory() {
    return loggerFactory;
}
Example 62
Project: sdk-dslink-java-master  File: StaticLoggerBinder.java View source code
@Override
public ILoggerFactory getLoggerFactory() {
    return factory;
}
Example 63
Project: slf4android-master  File: StaticLoggerBinder.java View source code
@Override
public ILoggerFactory getLoggerFactory() {
    return factory;
}
Example 64
Project: transactions-essentials-master  File: StaticLoggerBinder.java View source code
public ILoggerFactory getLoggerFactory() {
    return new ILoggerFactory() {

        public Logger getLogger(String clazz) {
            mockito = Mockito.mock(Logger.class);
            return mockito;
        }
    };
}
Example 65
Project: everBeen-master  File: StaticLoggerBinder.java View source code
@Override
public ILoggerFactory getLoggerFactory() {
    return factory;
}
Example 66
Project: myrobotlab-master  File: LoggerFactory.java View source code
public static ILoggerFactory getILoggerFactory() {
    return org.slf4j.LoggerFactory.getILoggerFactory();
}
Example 67
Project: turmeric-releng-master  File: StaticLoggerBinder.java View source code
@Override
public ILoggerFactory getLoggerFactory() {
    return loggerFactory;
}
Example 68
Project: consulo-master  File: StaticLoggerBinder.java View source code
@Override
public ILoggerFactory getLoggerFactory() {
    return myLoggerFactory;
}
Example 69
Project: cpool-master  File: StaticLoggerBinder.java View source code
public ILoggerFactory getLoggerFactory() {
    return loggerFactory;
}
Example 70
Project: grains-master  File: StaticLoggerBinder.java View source code
@Override
public ILoggerFactory getLoggerFactory() {
    return MavenLoggerFactory.INSTANCE;
}
Example 71
Project: kraken-master  File: StaticLoggerBinder.java View source code
@Override
public ILoggerFactory getLoggerFactory() {
    return loggerFactory;
}
Example 72
Project: microlog-master  File: StaticLoggerBinder.java View source code
public ILoggerFactory getLoggerFactory() {
    return loggerFactory;
}
Example 73
Project: microlog4android-master  File: StaticLoggerBinder.java View source code
public ILoggerFactory getLoggerFactory() {
    return loggerFactory;
}
Example 74
Project: Path-Computation-Element-Emulator-master  File: StaticLoggerBinder.java View source code
public ILoggerFactory getLoggerFactory() {
    return loggerFactory;
}
Example 75
Project: slf4j-timber-master  File: StaticLoggerBinder.java View source code
@Override
public ILoggerFactory getLoggerFactory() {
    return loggerFactory;
}
Example 76
Project: xmvn-master  File: StaticLoggerBinder.java View source code
@Override
public ILoggerFactory getLoggerFactory() {
    return FACTORY;
}
Example 77
Project: aether-core-master  File: Slf4jLoggerFactory.java View source code
public void initService(ServiceLocator locator) {
    setLoggerFactory(locator.getService(ILoggerFactory.class));
}
Example 78
Project: DependencyCheck-master  File: StaticLoggerBinder.java View source code
/**
     * Returns the logger factory.
     *
     * @return the logger factory
     */
@Override
public ILoggerFactory getLoggerFactory() {
    return loggerFactory;
}
Example 79
Project: cayenne-master  File: StaticLoggerBinder.java View source code
public ILoggerFactory getLoggerFactory() {
    return this.loggerFactory;
}
Example 80
Project: Chronicle-Logger-master  File: StaticLoggerBinder.java View source code
@Override
public ILoggerFactory getLoggerFactory() {
    return loggerFactory;
}
Example 81
Project: gradle-master  File: StaticLoggerBinder.java View source code
@Override
public ILoggerFactory getLoggerFactory() {
    return factory;
}
Example 82
Project: install4j-support-master  File: StaticLoggerBinder.java View source code
public ILoggerFactory getLoggerFactory() {
    return loggerFactory;
}
Example 83
Project: jdroid-master  File: LoggerUtils.java View source code
public static void setDefaultLoggerFactory(ILoggerFactory defaultLoggerFactory) {
    DEFAULT_LOGGER_FACTORY = defaultLoggerFactory;
}
Example 84
Project: liferay-portal-master  File: StaticLoggerBinder.java View source code
@Override
public ILoggerFactory getLoggerFactory() {
    return _iLoggerFactory;
}
Example 85
Project: midpoint-master  File: TraceManager.java View source code
public static ILoggerFactory getILoggerFactory() {
    return LoggerFactory.getILoggerFactory();
}
Example 86
Project: show-java-master  File: StaticLoggerBinder.java View source code
public ILoggerFactory getLoggerFactory() {
    return loggerFactory;
}
Example 87
Project: slf4j-jboss-logmanager-master  File: StaticLoggerBinder.java View source code
public ILoggerFactory getLoggerFactory() {
    return new Slf4jLoggerFactory();
}
Example 88
Project: teavm-master  File: TeaVMLoggerFactorySubstitution.java View source code
public static ILoggerFactory getILoggerFactory() {
    return loggerFactory;
}
Example 89
Project: karaf-master  File: StaticLoggerBinder.java View source code
public ILoggerFactory getLoggerFactory() {
    return loggerFactory;
}
Example 90
Project: log4j-slf4j-impl-patch-mtc-master  File: StaticLoggerBinder.java View source code
/**
     * Returns the factory.
     * @return the factor.
     */
@Override
public ILoggerFactory getLoggerFactory() {
    return loggerFactory;
}
Example 91
Project: logging-log4j2-master  File: StaticLoggerBinder.java View source code
/**
     * Returns the factory.
     * @return the factor.
     */
@Override
public ILoggerFactory getLoggerFactory() {
    return loggerFactory;
}
Example 92
Project: nexus-maven-plugins-master  File: LogbackModule.java View source code
@Override
protected void configure() {
    binder().bind(ILoggerFactory.class).toInstance(loggerContext);
}
Example 93
Project: OpenDJ-master  File: StaticLoggerBinder.java View source code
/** {@inheritDoc} */
@Override
public ILoggerFactory getLoggerFactory() {
    return loggerFactory;
}
Example 94
Project: SmallMind-master  File: StaticLoggerBinder.java View source code
public ILoggerFactory getLoggerFactory() {
    return loggerFactory;
}
Example 95
Project: acs-master  File: StaticLoggerBinder.java View source code
public ILoggerFactory getLoggerFactory() {
    return loggerFactory;
}
Example 96
Project: CIMTool-master  File: StaticLoggerBinder.java View source code
public ILoggerFactory getLoggerFactory() {
    return loggerFactory;
}
Example 97
Project: fullsync-master  File: StaticLoggerBinder.java View source code
@Override
public ILoggerFactory getLoggerFactory() {
    return loggerFactory;
}
Example 98
Project: iot-gateway-master  File: StaticLoggerBinder.java View source code
public ILoggerFactory getLoggerFactory() {
    return factory;
}
Example 99
Project: java-microedition-libraries-master  File: StaticLoggerBinder.java View source code
public ILoggerFactory getLoggerFactory() {
    throw new RuntimeException("This code should never make it into the jar");
}
Example 100
Project: mut4j-master  File: StaticLoggerBinder.java View source code
public ILoggerFactory getLoggerFactory() {
    throw new UnsupportedOperationException("This code should never make it into the jar");
}
Example 101
Project: org.ops4j.pax.logging-master  File: StaticLoggerBinder.java View source code
public ILoggerFactory getLoggerFactory() {
    return loggerFactory;
}