本文整理匯總了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
}
}
示例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);
}
}
示例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();
}
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
}
}
示例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();
}
示例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();
}