Java Code Examples for org.slf4j.bridge.SLF4JBridgeHandler#install()
The following examples show how to use
org.slf4j.bridge.SLF4JBridgeHandler#install() .
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: LOGBackConfigurer.java From styx with Apache License 2.0 | 6 votes |
/** * Initialize LOGBack from the given URL. * * @param url the url pointing to the location of the config file. * @param installJULBridge set to true to install SLF4J JUL bridge * @throws IllegalArgumentException if the url points to a non existing location or an error occurs during the parsing operation. */ public static void initLogging(URL url, boolean installJULBridge) { StaticLoggerBinder.getSingleton(); ContextSelector selector = ContextSelectorStaticBinder.getSingleton().getContextSelector(); LoggerContext loggerContext = selector.getLoggerContext(); loggerContext.stop(); ContextInitializer ctxi = new ContextInitializer(loggerContext); try { ctxi.configureByResource(url); loggerContext.start(); if (installJULBridge) { //uninstall already present handlers we want to //continue logging through SLF4J after this point Logger l = LogManager.getLogManager().getLogger(""); for (Handler h : l.getHandlers()) { l.removeHandler(h); } SLF4JBridgeHandler.install(); } } catch (JoranException e) { throw new IllegalArgumentException("exception while initializing LOGBack", e); } }
Example 2
Source File: JULBridge.java From dremio-oss with Apache License 2.0 | 6 votes |
public static void configure() { // Route JUL logging messages to SLF4J. LogManager.getLogManager().reset(); SLF4JBridgeHandler.removeHandlersForRootLogger(); SLF4JBridgeHandler.install(); // Parquet installs a default handler if none found, so remove existing handlers and add slf4j // one. // Also add slf4j bridge handle and configure additivity to false so that log messages are not // printed out twice final Handler[] handlers = PARQUET_ROOT_LOGGER.getHandlers(); for(int i = 0; i < handlers.length; i++) { PARQUET_ROOT_LOGGER.removeHandler(handlers[i]); } PARQUET_ROOT_LOGGER.addHandler(new SLF4JBridgeHandler()); PARQUET_ROOT_LOGGER.setUseParentHandlers(false); }
Example 3
Source File: ServerTest.java From raml-tester with Apache License 2.0 | 6 votes |
@Before public void initImpl() throws LifecycleException, ServletException { if (!inited.contains(getClass())) { inited.add(getClass()); SLF4JBridgeHandler.removeHandlersForRootLogger(); SLF4JBridgeHandler.install(); tomcat = new Tomcat(); tomcat.setPort(PORT); tomcat.setBaseDir("."); final Context ctx = tomcat.addWebapp("", "src/test"); ctx.setJarScanner(NO_SCAN); ((Host) ctx.getParent()).setAppBase(""); init(ctx); tomcat.start(); } }
Example 4
Source File: CitizenIntelligenceAgencyServer.java From cia with Apache License 2.0 | 5 votes |
/** * Inits the logger. */ private static void initLogger() { System.setProperty("logback.configurationFile", "src/main/resources/logback.xml"); System.setProperty("slf4j", "true"); System.setProperty("org.eclipse.jetty.util.log.class", "org.eclipse.jetty.util.log.Slf4jLog"); // System.setProperty("javax.net.debug", "all"); LogManager.getLogManager().reset(); SLF4JBridgeHandler.install(); java.util.logging.Logger.getLogger("global").setLevel(Level.FINEST); }
Example 5
Source File: JavaUtilLoggingConfigurer.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public void configure(LogLevel logLevel) { if (configured) { return; } LogManager.getLogManager().reset(); SLF4JBridgeHandler.install(); Logger.getLogger("").setLevel(java.util.logging.Level.FINE); configured = true; }
Example 6
Source File: SLF4JBridgeHandlerBundleActivator.java From jitsi-videobridge-openfire-plugin with Apache License 2.0 | 5 votes |
@Override public void start( BundleContext context ) throws Exception { // Remove existing handlers attached to j.u.l root logger SLF4JBridgeHandler.removeHandlersForRootLogger(); SLF4JBridgeHandler.install(); }
Example 7
Source File: PackageTest.java From jqm with Apache License 2.0 | 5 votes |
@Test(expected = NoResolvedResultException.class) public void testFailingDependency() throws Exception { jqmlogger.debug("**********************************************************"); jqmlogger.debug("Starting test testFailingDependency"); SLF4JBridgeHandler.install(); Maven.configureResolver() .withRemoteRepo(MavenRemoteRepositories.createRemoteRepository("marsu", "http://marsupilami.com", "default")) .withMavenCentralRepo(false).resolve("com.enioka.jqm:marsu:1.1.4").withTransitivity().asFile(); }
Example 8
Source File: BaleenLogging.java From baleen with Apache License 2.0 | 5 votes |
/** * Configure logging based on a list of builders provided to it. Injects the configured logging to * replace the default UIMA loggers, and also sets up metrics on the logging. * * @param builders The builders to use to configure the logging */ public void configure(List<BaleenLoggerBuilder> builders) { // Install JUL to SLF4J handling (JUL is default for UIMA) SLF4JBridgeHandler.removeHandlersForRootLogger(); SLF4JBridgeHandler.install(); // Configure Logback LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); Logger rootLogger = context.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME); // Install the level change propagator to reduce the impact of JUL logging context.addListener(new LevelChangePropagator()); // Remove all the existing appenders rootLogger.detachAndStopAllAppenders(); for (BaleenLoggerBuilder builder : builders) { PatternLayoutEncoder ple = new PatternLayoutEncoder(); ple.setCharset(StandardCharsets.UTF_8); ple.setContext(context); ple.setPattern(builder.getPattern()); ple.start(); Appender<ILoggingEvent> appender = builder.build(context, ple); if (!appender.isStarted()) { appender.start(); } rootLogger.addAppender(appender); } LOGGER.debug("Adding instrumented metrics for logging"); // Add an instrumented appender so we get the information about logging // through metrics InstrumentedAppender instrumentedAppender = new InstrumentedAppender(MetricsFactory.getInstance().getRegistry()); instrumentedAppender.setContext(context); instrumentedAppender.start(); rootLogger.addAppender(instrumentedAppender); }
Example 9
Source File: JulBridge.java From xio with Apache License 2.0 | 5 votes |
public static synchronized void initialize() { if (dummy == -1) { SLF4JBridgeHandler.removeHandlersForRootLogger(); SLF4JBridgeHandler.install(); dummy = 0; } }
Example 10
Source File: SecretInjectionIT.java From fernet-java8 with Apache License 2.0 | 5 votes |
protected Application configure() { SLF4JBridgeHandler.removeHandlersForRootLogger(); SLF4JBridgeHandler.install(); enable(TestProperties.LOG_TRAFFIC); return new ExampleSecretInjectionApplication<User>(); }
Example 11
Source File: Startup.java From db with GNU Affero General Public License v3.0 | 5 votes |
/** * Method starts the database package and it's libraries by loading all their bean factories each of which is * responsible to load it's own code henceforth. * * List of bean factories is maintained under {@code /src/main/resources/launcher-config.xml}. * * TODO: 1) I had a dream.. a dream that some day main functions will parse CLI arguments. * * @param args who cares.. for now.. */ public static void main(String[] args) { long startTime = System.currentTimeMillis(); logger.info("Starting BlobCity DB\""); // Pre-startup tasks below logger.debug("Configuring JUL Loggers"); SLF4JBridgeHandler.removeHandlersForRootLogger(); SLF4JBridgeHandler.install(); System.setProperty("jna.debug_load", "true"); System.setProperty("jna.debug_load.jna", "true"); // System.setProperty("java.library.path", "/lib"); System.setProperty("jna.library.path", "/lib64"); // Startup tasks below logger.debug("Performing database launch tasks"); try { loadBeanConfigs(); // This task launches the database // Any other future tasks can go here as method class initEngine(); } catch (ClassNotFoundException ex) { logger.error("Launching BlobCity DB has failed!", ex); } logger.info("BlobCity DB successfully started in " + (System.currentTimeMillis() - startTime) / 1000 + " seconds"); logger.info("Setting log level to ERROR. Change by using set-log-level {log_level} CLI command"); LogManager.getRootLogger().setLevel(org.apache.log4j.Level.ERROR); // it is assumed that startup failures are managed and appropriate logs are generated }
Example 12
Source File: GraphReaderExample.java From restfb-examples with MIT License | 5 votes |
/** * Entry point. You must provide a single argument on the command line: a valid Graph API access token. * * @param args * Command-line arguments. * @throws IllegalArgumentException * If no command-line arguments are provided. */ public static void main(String[] args) { if (args.length == 0) throw new IllegalArgumentException( "You must provide an OAuth access token parameter. See README for more information."); SLF4JBridgeHandler.removeHandlersForRootLogger(); SLF4JBridgeHandler.install(); new GraphReaderExample(args[0]).runEverything(); }
Example 13
Source File: SLF4JBridgeActivator.java From gazpachoquest with GNU General Public License v3.0 | 5 votes |
@Override public void contextInitialized(ServletContextEvent sce) { logger.info("Bridging JUL to SLF4"); // Jersey uses java.util.logging - bridge to slf4 SLF4JBridgeHandler.removeHandlersForRootLogger(); SLF4JBridgeHandler.install(); }
Example 14
Source File: BasicActionTest.java From crnk-framework with Apache License 2.0 | 4 votes |
@Before public void setup() { SLF4JBridgeHandler.install(); super.setup(); scheduleRepo = client.getRepositoryForInterface(ScheduleRepository.class); }
Example 15
Source File: JustTestLahRunner.java From justtestlah with Apache License 2.0 | 4 votes |
private void bridgeLogging() { SLF4JBridgeHandler.removeHandlersForRootLogger(); SLF4JBridgeHandler.install(); }
Example 16
Source File: AsciidocEngine.java From helidon-build-tools with Apache License 2.0 | 4 votes |
/** * Setup the SLF4J to JUL bridge. */ private static void installSLF4JBridge(){ SLF4JBridgeHandler.removeHandlersForRootLogger(); SLF4JBridgeHandler.install(); }
Example 17
Source File: MuteJUL.java From barge with Apache License 2.0 | 4 votes |
@Override protected void before() throws Throwable { Logger.getLogger("").setLevel(Level.ALL); SLF4JBridgeHandler.removeHandlersForRootLogger(); SLF4JBridgeHandler.install(); }
Example 18
Source File: NiFi.java From nifi with Apache License 2.0 | 4 votes |
protected void initLogging() { SLF4JBridgeHandler.removeHandlersForRootLogger(); SLF4JBridgeHandler.install(); }
Example 19
Source File: Runner.java From grpc-proxy with Apache License 2.0 | 4 votes |
public static void main(String[] args) { SLF4JBridgeHandler.removeHandlersForRootLogger(); SLF4JBridgeHandler.install(); cli().parse(args).run(); }
Example 20
Source File: PortMapperStarter.java From portmapper with GNU General Public License v3.0 | 4 votes |
private static void redirectJavaUtilLoggingToLogback() { SLF4JBridgeHandler.removeHandlersForRootLogger(); SLF4JBridgeHandler.install(); }