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