本文整理汇总了Java中org.slf4j.bridge.SLF4JBridgeHandler.removeHandlersForRootLogger方法的典型用法代码示例。如果您正苦于以下问题:Java SLF4JBridgeHandler.removeHandlersForRootLogger方法的具体用法?Java SLF4JBridgeHandler.removeHandlersForRootLogger怎么用?Java SLF4JBridgeHandler.removeHandlersForRootLogger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.slf4j.bridge.SLF4JBridgeHandler
的用法示例。
在下文中一共展示了SLF4JBridgeHandler.removeHandlersForRootLogger方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例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, 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);
}
示例4: 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);
}
示例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: 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();
}
}
示例8: 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);
}
示例9: 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();
}
示例10: 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();
}
示例11: startTomcat
import org.slf4j.bridge.SLF4JBridgeHandler; //导入方法依赖的package包/类
@BeforeClass
public static void startTomcat() throws ServletException, LifecycleException {
SLF4JBridgeHandler.removeHandlersForRootLogger();
SLF4JBridgeHandler.install();
tomcat = new Tomcat();
tomcat.setPort(8081);
tomcat.setBaseDir(".");
Context ctx = tomcat.addWebapp("/", "src/main/webapp");
ctx.setJarScanner(new JarScanner() {
@Override
public void scan(ServletContext context, ClassLoader classloader, JarScannerCallback callback, Set<String> jarsToSkip) {
}
});
((Host) ctx.getParent()).setAppBase("");
tomcat.start();
server = tomcat.getServer();
server.start();
}
示例12: 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();
}
示例13: OSClientFactory
import org.slf4j.bridge.SLF4JBridgeHandler; //导入方法依赖的package包/类
/**
* Creates an {@link OSClientFactory} with a custom {@link OSClientCreator}.
*
* @param apiAccessConfig
* API access configuration that describes how to authenticate
* with and communicate over the OpenStack API.
*
*/
public OSClientFactory(ApiAccessConfig apiAccessConfig, OSClientBuilder clientBuilder) {
checkArgument(apiAccessConfig != null, "no apiAccessConfig given");
checkArgument(clientBuilder != null, "no clientBuilder given");
apiAccessConfig.validate();
this.apiAccessConfig = apiAccessConfig;
this.clientBuilder = clientBuilder;
if (apiAccessConfig.shouldLogHttpRequests()) {
LOG.debug("setting up HTTP request logging");
// enable logging of each http request from openstack4j
OSFactory.enableHttpLoggingFilter(true);
// Install slf4j logging bridge to capture java.util.logging output
// from the openstack4j. NOTE: the logger appears to be named 'os'.
SLF4JBridgeHandler.removeHandlersForRootLogger();
SLF4JBridgeHandler.install();
}
}
示例14: initImpl
import org.slf4j.bridge.SLF4JBridgeHandler; //导入方法依赖的package包/类
@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();
}
}
示例15: start
import org.slf4j.bridge.SLF4JBridgeHandler; //导入方法依赖的package包/类
private void start() throws LifecycleException, ServletException {
SLF4JBridgeHandler.removeHandlersForRootLogger();
SLF4JBridgeHandler.install();
tomcat = new Tomcat();
tomcat.setPort(port);
tomcat.setBaseDir(".");
Context ctx = tomcat.addWebapp("", Ramls.clientDir("src/test"));
ctx.setJarScanner(NO_SCAN);
((Host) ctx.getParent()).setAppBase("");
contextIniter.initContext(ctx);
tomcat.start();
Server server = tomcat.getServer();
server.start();
}