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


Java SLF4JBridgeHandler類代碼示例

本文整理匯總了Java中org.slf4j.bridge.SLF4JBridgeHandler的典型用法代碼示例。如果您正苦於以下問題:Java SLF4JBridgeHandler類的具體用法?Java SLF4JBridgeHandler怎麽用?Java SLF4JBridgeHandler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: init

import org.slf4j.bridge.SLF4JBridgeHandler; //導入依賴的package包/類
@Override
public void init() {
    SLF4JBridgeHandler.removeHandlersForRootLogger();
    SLF4JBridgeHandler.install();
    final List<String> keyList = new LinkedList<>();
    final List<String> valueList = new LinkedList<>();
    if (!Strings.isNullOrEmpty(SecondBase.serviceName)) {
        keyList.add("service");
        valueList.add(SecondBase.serviceName);
    }
    if (!Strings.isNullOrEmpty(SecondBase.environment)) {
        keyList.add("environment");
        valueList.add(SecondBase.environment);
    }
    if (!Strings.isNullOrEmpty(JsonLoggerConfiguration.datacenter)) {
        keyList.add("datacenter");
        valueList.add(JsonLoggerConfiguration.datacenter);
    }
    SecondBaseLogger.setupLoggingStdoutOnly(
            keyList.toArray(new String[] {}),
            valueList.toArray(new String[] {}),
            JsonLoggerConfiguration.requestLoggerClassName,
            true);
}
 
開發者ID:secondbase,項目名稱:secondbase,代碼行數:25,代碼來源:JsonLoggerModule.java

示例2: start

import org.slf4j.bridge.SLF4JBridgeHandler; //導入依賴的package包/類
public TestServiceRunnerJetty.Runtime start() {

        SLF4JBridgeHandler.removeHandlersForRootLogger();
        SLF4JBridgeHandler.install();
        ServiceConfig serviceConfigwithProps = serviceConfig.addPropertiesAndApplyToBindings(propertyMap);
        ServiceRunner serviceRunner = new ServiceRunner(serviceConfigwithProps, propertyMap);
        ServiceRunner runningServiceRunner = serviceRunner.start();

        URI uri = runningServiceRunner.jettyServer.server.getURI();
        uri = UriBuilder.fromUri(uri).host("localhost").build();

        ClientGenerator clientGenerator = clientConfigurator.apply(
                ClientGenerator.defaults(serviceConfigwithProps.serviceDefinition)
        );
        Client client = clientGenerator.generate();
        StubGenerator stubGenerator = stubConfigurator.apply(StubGenerator.defaults(client, UriBuilder.fromUri(uri).build()));

        TargetGenerator targetGenerator = targetConfigurator.apply(TargetGenerator.defaults(client, uri));

        return new Runtime(runningServiceRunner, uri, stubGenerator, clientGenerator, targetGenerator);
    }
 
開發者ID:code-obos,項目名稱:servicebuilder,代碼行數:22,代碼來源:TestServiceRunnerJetty.java

示例3: setup

import org.slf4j.bridge.SLF4JBridgeHandler; //導入依賴的package包/類
@BeforeClass
    public static void setup() throws NodeValidationException, IOException {
        SLF4JBridgeHandler.removeHandlersForRootLogger();
        SLF4JBridgeHandler.install();

        ServiceConfig serviceConfig = ServiceConfig
                .defaults(ServiceDefinitionUtil.simple(Resource.class))
                .addon(ElasticsearchAddonMockImpl.defaults)
//                .addon(ElasticsearchAddonImpl.defaults
//                        .coordinatorPort(9300)
//                        .coordinatorUrl("127.0.0.1")
//                        .clustername("test-search-api-5-local_jonas")
//                        .clientname("banan")
//                        .unitTest(true)
//                )
                .addon(ExceptionMapperAddon.defaults)
                .addon(ServerLogAddon.defaults)
                .addon(ElasticsearchIndexAddon.defaults("oneIndex", TestService.Payload.class)
                        .doIndexing(true)
                )
                .bind(ResourceImpl.class, Resource.class);
        testServiceRunner = TestServiceRunner.defaults(serviceConfig);
        TestServiceRunner.defaults(serviceConfig);
    }
 
開發者ID:code-obos,項目名稱:servicebuilder,代碼行數:25,代碼來源:IndexerTest.java

示例4: setup

import org.slf4j.bridge.SLF4JBridgeHandler; //導入依賴的package包/類
@BeforeClass
public static void setup() throws NodeValidationException, UnknownHostException {
    SLF4JBridgeHandler.removeHandlersForRootLogger();
    SLF4JBridgeHandler.install();

    ServiceConfig serviceConfig = ServiceConfig
            .defaults(ServiceDefinitionUtil.simple(Resource.class))
            .addon(ExceptionMapperAddon.defaults)
            .addon(ServerLogAddon.defaults)
            .addon(ElasticsearchAddonMockImpl.defaults)
            .addon(ElasticsearchIndexAddon.defaults("oneIndex", TestService.Payload.class))
            .addon(ElasticsearchIndexAddon.defaults("anotherIndex", String.class))
            .bind(ResourceImpl.class, Resource.class);
    testServiceRunner = TestServiceRunner.defaults(serviceConfig);
    TestServiceRunner.defaults(serviceConfig);
}
 
開發者ID:code-obos,項目名稱:servicebuilder,代碼行數:17,代碼來源:SearcherTest.java

示例5: CCOWContextListener

import org.slf4j.bridge.SLF4JBridgeHandler; //導入依賴的package包/類
public CCOWContextListener(final ContextState commonContext, final Module... behaviourModules) {
	super();
	SLF4JBridgeHandler.removeHandlersForRootLogger();
	SLF4JBridgeHandler.install();
	logger.info("Starting up servlet ...");
	this.modules = ImmutableList.<Module> builder().add(behaviourModules).add(new EndpointModule(commonContext))
			.add(new JerseyServletModule() {

				@Override
				protected void configureServlets() {
					final Map<String, String> params = ImmutableMap.<String, String> builder()
							.put(ResourceConfig.PROPERTY_CONTAINER_RESPONSE_FILTERS,
									GZIPContentEncodingFilter.class.getName())
							.build();
					bind(CORSFilter.class).in(Singleton.class);
					bind(UrlRewriteFilter.class).in(Singleton.class);
					serve("/*").with(GuiceContainer.class, params);
					filter("/*").through(CORSFilter.class);
					filter("/*").through(UrlRewriteFilter.class);

					requestStaticInjection(WebSocketsConfigurator.class);
				}
			}).build();
}
 
開發者ID:jkiddo,項目名稱:ccow,代碼行數:25,代碼來源:CCOWContextListener.java

示例6: initializeLogback

import org.slf4j.bridge.SLF4JBridgeHandler; //導入依賴的package包/類
private void initializeLogback() {
    Path logbackFilePath = Paths.get(configPath, "logback.xml");
    if (logbackFilePath.toFile().exists()) {
        try {
            // Load logback configuration
            LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
            context.reset();
            JoranConfigurator configurator = new JoranConfigurator();
            configurator.setContext(context);
            configurator.doConfigure(logbackFilePath.toFile());

            // Install java.util.logging bridge
            SLF4JBridgeHandler.removeHandlersForRootLogger();
            SLF4JBridgeHandler.install();
        } catch (JoranException e) {
            throw new GossipInitializeException("Misconfiguration on logback.xml, check it.", e);
        }
    }
}
 
開發者ID:syhily,項目名稱:gossip,代碼行數:20,代碼來源:GossipLogModule.java

示例7: initialize

import org.slf4j.bridge.SLF4JBridgeHandler; //導入依賴的package包/類
/**
 * Initialize Logging
 *
 * @param isClient client
 */
public static void initialize(final boolean isClient)
{
	if (s_initialized.getAndSet(true))
	{
		return;
	}

	//
	// Forward all logs from JUL to SLF4J
	{
		SLF4JBridgeHandler.uninstall();
		SLF4JBridgeHandler.install();
	}

	if (isClient)
	{
		// FRESH-267: in server mode, do not (re)set the loglevels. They are coming out of logback.xml and/or application properties and were probably fine-tuned.
		// resetting them to info might cause the disk to run full.
		setLevel(Level.INFO);
	}
}
 
開發者ID:metasfresh,項目名稱:metasfresh,代碼行數:27,代碼來源:LogManager.java

示例8: startIfRequired

import org.slf4j.bridge.SLF4JBridgeHandler; //導入依賴的package包/類
public static void startIfRequired() throws Exception
{
    if (server == null) {
    	
        SLF4JBridgeHandler.removeHandlersForRootLogger();
        SLF4JBridgeHandler.install();
         
        server = new Server(TEST_PORT);
 
        WebAppContext context = new WebAppContext();
        context.setDescriptor("src/test/resources/jetty/WEB-INF/web.xml");
        context.setResourceBase("src/main/webapp");
        context.setContextPath(TEST_CONTEXT);
        context.setParentLoaderPriority(true);
 
        server.setHandler(context);
 
        server.start();
    }
}
 
開發者ID:xtivia,項目名稱:xsf,代碼行數:21,代碼來源:JettyServer.java

示例9: installJulBridge

import org.slf4j.bridge.SLF4JBridgeHandler; //導入依賴的package包/類
private void installJulBridge() {
  // Workaround for strange ClassCircularityErrors in the JUL bridge when very
  // strange classloader hierarchies are
  // set up and logging occurs from inside classloaders themselves (eg: some
  // strange Tomcat deployments)
  try {
    Class.forName("java.util.logging.LogRecord");
  } catch (ClassNotFoundException e) {
    throw new AssertionError(e);
  }

  LoggerContext loggerContext = (LoggerContext) getContext();

  if (!SLF4JBridgeHandler.isInstalled()) {
    SLF4JBridgeHandler.removeHandlersForRootLogger();
    SLF4JBridgeHandler.install();
  }
  LevelChangePropagator julLevelChanger = new LevelChangePropagator();
  julLevelChanger.setContext(loggerContext);
  julLevelChanger.setResetJUL(true);
  julLevelChanger.start();
  loggerContext.addListener(julLevelChanger);
}
 
開發者ID:irenical,項目名稱:jindy,代碼行數:24,代碼來源:LoggerConfigurator.java

示例10: start

import org.slf4j.bridge.SLF4JBridgeHandler; //導入依賴的package包/類
public void start(BundleContext context) throws Exception {
	createUUIDFile();
	
	String versionString = context.getBundle().getVersion().toString();
	// if the version string contains a qualifier, remove it!
	if (StringUtils.countMatches(versionString, ".") == 3) {
		versionString = StringUtils.substringBeforeLast(versionString, ".");
	}
	createVersionFile(versionString);
	
	logger.info("openHAB runtime has been started (v{}).", versionString);

	java.util.logging.Logger rootLogger = java.util.logging.LogManager.getLogManager().getLogger("");
	Handler[] handlers = rootLogger.getHandlers();
	for (Handler handler : handlers) {
		rootLogger.removeHandler(handler);
	}
	
	SLF4JBridgeHandler.install();
}
 
開發者ID:andrey-desman,項目名稱:openhab-hdl,代碼行數:21,代碼來源:CoreActivator.java

示例11: startServer

import org.slf4j.bridge.SLF4JBridgeHandler; //導入依賴的package包/類
/** Starts the server with HTTPS. */
@BeforeClass
public static void startServer() throws Exception {
    SLF4JBridgeHandler.removeHandlersForRootLogger();
    SLF4JBridgeHandler.install();

    ssc = new SelfSignedCertificate("example.com");
    ServerBuilder sb = new ServerBuilder()
            .port(0, SessionProtocol.HTTPS)
            .defaultMaxRequestLength(16 * 1024 * 1024)
            .sslContext(GrpcSslContexts.forServer(ssc.certificate(), ssc.privateKey())
                                       .applicationProtocolConfig(ALPN)
                                       .trustManager(TestUtils.loadCert("ca.pem"))
                                       .build());

    final ArmeriaGrpcServerBuilder builder = new ArmeriaGrpcServerBuilder(sb, new GrpcServiceBuilder(),
                                                                          ctxCapture);
    startStaticServer(builder);
    server = builder.builtServer();
}
 
開發者ID:line,項目名稱:armeria,代碼行數:21,代碼來源:ArmeriaGrpcServerInteropTest.java

示例12: main

import org.slf4j.bridge.SLF4JBridgeHandler; //導入依賴的package包/類
public static void main(final String... args) throws Exception {
    SLF4JBridgeHandler.removeHandlersForRootLogger();
    SLF4JBridgeHandler.install();

    final App app = new App();
    app.startServer();

    Injector injector = app.getInjector();

    // Bootstrap the database
    final Bootstrapper bootstrappper = injector.getInstance(Bootstrapper.class);
    bootstrappper.parseFromResource("/bootstrap/test-bootstrapper.json");

    // Init inserted rooms
    final RoomBackend roomBackend = injector.getInstance(RoomBackend.class);
    roomBackend.initializeRooms();

    app.joinThread();
}
 
開發者ID:MoodCat,項目名稱:MoodCat.me-Core,代碼行數:20,代碼來源:TestPackageAppRunner.java

示例13: LoggingConfig

import org.slf4j.bridge.SLF4JBridgeHandler; //導入依賴的package包/類
/**
 * Constructor.
 */
public LoggingConfig() {
   boolean bridgeJULtoSLF4J = ConfigManager.getInstance().getBoolean("logging.bridgeJULtoSLF4J", true);

   if (bridgeJULtoSLF4J) {
      try {
         // Remove existing handlers
         Logger rootLogger = LoggingConfig.getRootLogger();
         Handler[] handlers = rootLogger.getHandlers();
         for (Handler handler : handlers) {
            rootLogger.removeHandler(handler);
         }

         // Install bridge handler as only handler
         SLF4JBridgeHandler bridgeToSlf4j = new SLF4JBridgeHandler();
         rootLogger.addHandler(bridgeToSlf4j);
      } catch (Exception e) {
         System.err.println("Unable to configure java logging due to exception: " + e.getMessage());
         e.printStackTrace();
      }
   }
}
 
開發者ID:scratch-wireless,項目名稱:kazoo-client,代碼行數:25,代碼來源:LoggingConfig.java

示例14: main

import org.slf4j.bridge.SLF4JBridgeHandler; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
    SLF4JBridgeHandler.removeHandlersForRootLogger();
    SLF4JBridgeHandler.install();
    Server server = new Server(9090);
    ClassList classlist = Configuration.ClassList.setServerDefault(server);
    classlist.addBefore("org.eclipse.jetty.webapp.JettyWebXmlConfiguration", "org.eclipse.jetty.annotations.AnnotationConfiguration");
    WebAppContext webapp = new WebAppContext();
    webapp.setParentLoaderPriority(true);
    webapp.setConfigurationDiscovered(true);
    webapp.setContextPath("/");
    webapp.setResourceBase("src/main/webapp");
    webapp.setWar("src/main/webapp");       
    ServletHolder servletHolder = webapp.addServlet(DemoUIServlet.class, "/*");
    servletHolder.setAsyncSupported(true);
    servletHolder.setInitParameter("org.atmosphere.cpr.asyncSupport", JSR356AsyncSupport.class.getName());
    server.setHandler(webapp);
    ServerContainer webSocketServer = WebSocketServerContainerInitializer.configureContext(webapp);
    webSocketServer.setDefaultMaxSessionIdleTimeout(10000000);        
    server.start();
    log.info("Browse http://localhost:9090 to see the demo");
    server.join();
}
 
開發者ID:JumpMind,項目名稱:sqlexplorer-vaadin,代碼行數:23,代碼來源:DemoUI.java

示例15: init

import org.slf4j.bridge.SLF4JBridgeHandler; //導入依賴的package包/類
/** slf4j / Logback initialization */
private static void init() throws SecurityException, IllegalStateException {
    final LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
    final URL logConf = ResourceUtils.getResource(JMMC_LOGBACK_CONFIG_RESOURCE);
    try {
        final JoranConfigurator configurator = new JoranConfigurator();
        configurator.setContext(loggerContext);
        loggerContext.reset();
        configurator.doConfigure(logConf.openStream());
    } catch (IOException ioe) {
        throw new IllegalStateException("IO Exception occured", ioe);
    } catch (JoranException je) {
        StatusPrinter.printInCaseOfErrorsOrWarnings((LoggerContext) LoggerFactory.getILoggerFactory());
    }

    // Remove existing handlers attached to j.u.l root logger
    SLF4JBridgeHandler.removeHandlersForRootLogger();  // (since SLF4J 1.6.5)

    // add SLF4JBridgeHandler to j.u.l's root logger, should be done once during
    // the initialization phase of your application
    SLF4JBridgeHandler.install();
}
 
開發者ID:JMMC-OpenDev,項目名稱:jMCS,代碼行數:23,代碼來源:LoggingService.java


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