Example usage for io.netty.util.internal.logging Slf4JLoggerFactory INSTANCE

List of usage examples for io.netty.util.internal.logging Slf4JLoggerFactory INSTANCE

Introduction

In this page you can find the example usage for io.netty.util.internal.logging Slf4JLoggerFactory INSTANCE.

Prototype

InternalLoggerFactory INSTANCE

To view the source code for io.netty.util.internal.logging Slf4JLoggerFactory INSTANCE.

Click Source Link

Usage

From source file:cc.agentx.client.net.nio.XClient.java

License:Apache License

public void start() {
    Configuration config = Configuration.INSTANCE;
    InternalLoggerFactory.setDefaultFactory(Slf4JLoggerFactory.INSTANCE);
    bossGroup = new NioEventLoopGroup(1);
    workerGroup = new NioEventLoopGroup();
    try {//from   w ww  . j a  va  2  s .com
        ServerBootstrap bootstrap = new ServerBootstrap();
        bootstrap.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
                .childHandler(new ChannelInitializer<SocketChannel>() {
                    @Override
                    protected void initChannel(SocketChannel socketChannel) throws Exception {
                        socketChannel.pipeline().addLast("logging", new LoggingHandler(LogLevel.DEBUG))
                                .addLast(new SocksInitRequestDecoder()).addLast(new SocksMessageEncoder())
                                .addLast(new Socks5Handler()).addLast(Status.TRAFFIC_HANDLER);
                    }
                });
        log.info("\tStartup {}-{}-client [{}{}]", Constants.APP_NAME, Constants.APP_VERSION, config.getMode(),
                config.getMode().equals("socks5") ? "" : ":" + config.getProtocol());
        ChannelFuture future = bootstrap.bind(config.getLocalHost(), config.getLocalPort()).sync();
        future.addListener(
                future1 -> log.info("\tListening at {}:{}...", config.getLocalHost(), config.getLocalPort()));
        future.channel().closeFuture().sync();
    } catch (Exception e) {
        log.error("\tSocket bind failure ({})", e.getMessage());
    } finally {
        log.info("\tShutting down");
        bossGroup.shutdownGracefully();
        workerGroup.shutdownGracefully();
    }
}

From source file:cc.agentx.server.net.nio.XServer.java

License:Apache License

public void start() {
    Configuration config = Configuration.INSTANCE;
    InternalLoggerFactory.setDefaultFactory(Slf4JLoggerFactory.INSTANCE);
    EventLoopGroup bossGroup = new NioEventLoopGroup(1);
    EventLoopGroup workerGroup = new NioEventLoopGroup();
    try {// w w  w . j a va2  s.c o m
        ServerBootstrap bootstrap = new ServerBootstrap();
        bootstrap.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
                .childHandler(new ChannelInitializer<SocketChannel>() {
                    protected void initChannel(SocketChannel socketChannel) throws Exception {
                        socketChannel.pipeline().addLast("logging", new LoggingHandler(LogLevel.DEBUG))
                                .addLast(new XConnectHandler());
                        if (config.getReadLimit() != 0 || config.getWriteLimit() != 0) {
                            socketChannel.pipeline().addLast(
                                    new GlobalTrafficShapingHandler(Executors.newScheduledThreadPool(1),
                                            config.getWriteLimit(), config.getReadLimit()));
                        }
                    }
                });
        log.info("\tStartup {}-{}-server [{}]", Constants.APP_NAME, Constants.APP_VERSION,
                config.getProtocol());
        ChannelFuture future = bootstrap.bind(config.getHost(), config.getPort()).sync();
        future.addListener(future1 -> log.info("\tListening at {}:{}...", config.getHost(), config.getPort()));
        future.channel().closeFuture().sync();
    } catch (Exception e) {
        log.error("\tSocket bind failure ({})", e.getMessage());
    } finally {
        log.info("\tShutting down and recycling...");
        bossGroup.shutdownGracefully();
        workerGroup.shutdownGracefully();
        Configuration.shutdownRelays();
    }
    System.exit(0);
}

From source file:com.heliosapm.tsdblite.TSDBLite.java

License:Apache License

/**
 * Main entry point//from w w  w  .  j a  v a 2s . c o m
 * @param args None for now
 */
public static void main(String[] args) {
    log.info("TSDBLite booting....");
    ExtendedThreadManager.install();
    InternalLoggerFactory.setDefaultFactory(Slf4JLoggerFactory.INSTANCE);
    final String jmxmpIface = ConfigurationHelper.getSystemThenEnvProperty(Constants.CONF_JMXMP_IFACE,
            Constants.DEFAULT_JMXMP_IFACE);
    final int jmxmpPort = ConfigurationHelper.getIntSystemThenEnvProperty(Constants.CONF_JMXMP_PORT,
            Constants.DEFAULT_JMXMP_PORT);
    JMXHelper.fireUpJMXMPServer(jmxmpIface, jmxmpPort, JMXHelper.getHeliosMBeanServer());
    server = Server.getInstance();
    final Thread mainThread = Thread.currentThread();
    StdInCommandHandler.getInstance().registerCommand("stop", new Runnable() {
        @Override
        public void run() {
            if (server != null) {
                log.info("Stopping TSDBLite Server.....");
                server.stop();
                log.info("TSDBLite Server Stopped. Bye.");
                mainThread.interrupt();
            }
        }
    });
    try {
        Thread.currentThread().join();
    } catch (Exception x) {
        /* No Op */}
}

From source file:io.gravitee.gateway.standalone.AbstractGatewayTest.java

License:Apache License

@BeforeClass
public static void init() {
    InternalLoggerFactory.setDefaultFactory(Slf4JLoggerFactory.INSTANCE);
}

From source file:io.pravega.segmentstore.server.host.handler.PravegaConnectionListener.java

License:Open Source License

public PravegaConnectionListener(boolean ssl, String host, int port, StreamSegmentStore streamSegmentStore,
        SegmentStatsRecorder statsRecorder) {
    this.ssl = ssl;
    this.host = host;
    this.port = port;
    this.store = streamSegmentStore;
    this.statsRecorder = statsRecorder;
    InternalLoggerFactory.setDefaultFactory(Slf4JLoggerFactory.INSTANCE);
}

From source file:io.pravega.test.integration.AppendTest.java

License:Open Source License

@Before
public void setup() throws Exception {
    originalLevel = ResourceLeakDetector.getLevel();
    ResourceLeakDetector.setLevel(Level.PARANOID);
    InternalLoggerFactory.setDefaultFactory(Slf4JLoggerFactory.INSTANCE);
    this.serviceBuilder = ServiceBuilder.newInMemoryBuilder(ServiceBuilderConfig.getDefaultConfig());
    this.serviceBuilder.initialize();
}

From source file:io.pravega.test.integration.CheckpointTest.java

License:Open Source License

@Before
public void setup() throws Exception {
    InternalLoggerFactory.setDefaultFactory(Slf4JLoggerFactory.INSTANCE);
    this.serviceBuilder = ServiceBuilder.newInMemoryBuilder(ServiceBuilderConfig.getDefaultConfig());
    this.serviceBuilder.initialize();
}

From source file:io.reactivesocket.cli.Main.java

License:Apache License

public void run() throws IOException, URISyntaxException, InterruptedException {
    System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", debug ? "debug" : "warn");

    retainedLogger = LoggerFactory.getLogger("");

    InternalLoggerFactory.setDefaultFactory(Slf4JLoggerFactory.INSTANCE);

    if (outputHandler == null) {
        outputHandler = new ConsoleOutputHandler();
    }//from w w  w  .  j  a v  a  2  s  . co  m

    try {
        URI uri = new URI(arguments.get(0));

        if (serverMode) {
            server = ReactiveSocketServer.create(ConnectionHelper.buildServerConnection(uri))
                    .start((setupPayload, reactiveSocket) -> new DisabledLeaseAcceptingSocket(
                            createServerRequestHandler(setupPayload)));

            server.awaitShutdown();
        } else {
            client = Flowable.fromPublisher(ReactiveSocketClient
                    .create(ConnectionHelper.buildClientConnection(uri), keepAlive(never()).disableLease())
                    .connect()).blockingFirst();

            Completable run = run(client);
            run.await();
        }
    } catch (Exception e) {
        outputHandler.error("error", e);
    } finally {
        ClientState.defaultEventloopGroup().shutdownGracefully();
    }
}

From source file:org.glowroot.ui.HttpServer.java

License:Apache License

HttpServer(String bindAddress, int port, int numWorkerThreads, ConfigRepository configRepository,
        CommonHandler commonHandler, File certificateDir) throws Exception {

    InternalLoggerFactory.setDefaultFactory(Slf4JLoggerFactory.INSTANCE);

    ThreadFactory bossThreadFactory = new ThreadFactoryBuilder().setDaemon(true)
            .setNameFormat("Glowroot-Http-Boss").build();
    ThreadFactory workerThreadFactory = new ThreadFactoryBuilder().setDaemon(true)
            .setNameFormat("Glowroot-Http-Worker-%d").build();
    bossGroup = new NioEventLoopGroup(1, bossThreadFactory);
    workerGroup = new NioEventLoopGroup(numWorkerThreads, workerThreadFactory);

    final HttpServerHandler handler = new HttpServerHandler(configRepository, commonHandler);

    if (configRepository.getWebConfig().https()) {
        sslContext = SslContextBuilder//from  w  ww  . ja va 2s  . co m
                .forServer(new File(certificateDir, "certificate.pem"), new File(certificateDir, "private.pem"))
                .build();
    }
    this.certificateDir = certificateDir;

    bootstrap = new ServerBootstrap();
    bootstrap.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
            .childHandler(new ChannelInitializer<SocketChannel>() {
                @Override
                protected void initChannel(SocketChannel ch) throws Exception {
                    ChannelPipeline p = ch.pipeline();
                    SslContext sslContextLocal = sslContext;
                    if (sslContextLocal != null) {
                        p.addLast(sslContextLocal.newHandler(ch.alloc()));
                    }
                    // bumping maxInitialLineLength (first arg below) from default 4096 to 32768
                    // in order to handle long urls on /jvm/gauges view
                    // bumping maxHeaderSize (second arg below) from default 8192 to 32768 for
                    // same reason due to "Referer" header once url becomes huge
                    // leaving maxChunkSize (third arg below) at default 8192
                    p.addLast(new HttpServerCodec(32768, 32768, 8192));
                    p.addLast(new HttpObjectAggregator(1048576));
                    p.addLast(new ConditionalHttpContentCompressor());
                    p.addLast(new ChunkedWriteHandler());
                    p.addLast(handler);
                }
            });
    this.handler = handler;
    logger.debug("<init>(): binding http server to port {}", port);
    this.bindAddress = bindAddress;
    Channel serverChannel;
    try {
        serverChannel = bootstrap.bind(new InetSocketAddress(bindAddress, port)).sync().channel();
    } catch (Exception e) {
        // FailedChannelFuture.sync() is using UNSAFE to re-throw checked exceptions
        bossGroup.shutdownGracefully(0, 0, SECONDS);
        workerGroup.shutdownGracefully(0, 0, SECONDS);
        throw new SocketBindException(e);
    }
    this.serverChannel = serverChannel;
    this.port = ((InetSocketAddress) serverChannel.localAddress()).getPort();
    logger.debug("<init>(): http server bound");
}

From source file:org.sonarlint.daemon.Daemon.java

License:Open Source License

private static void setUpNettyLogging() {
    InternalLoggerFactory.setDefaultFactory(Slf4JLoggerFactory.INSTANCE);
}