List of usage examples for io.netty.handler.logging LogLevel DEBUG
LogLevel DEBUG
To view the source code for io.netty.handler.logging LogLevel DEBUG.
Click Source Link
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 w w.ja va 2 s . c om 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 {/*from w w w . j a v a2s .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.artigile.homestats.HomeStatsServer.java
License:Apache License
public static void main(String[] args) throws Exception { ArgsParser argsParser = new ArgsParser(args); if (argsParser.isDisplayHelp()) { ArgsParser.printHelp();/* w ww . java2 s. c o m*/ return; } EventLoopGroup bossGroup = null; EventLoopGroup workerGroup = null; try { SensorMode appMode = SensorMode .valueOf(argsParser.getString(ArgsParser.APP_MODE_OPTION, "dev").toUpperCase()); SensorsDataProvider sensorsDataProvider = SensorFactory.buildSensorDataProvider(appMode); if (sensorsDataProvider == null) { LOGGER.error("No sensor device available, quitting."); return; } final boolean printAndExit = argsParser.argumentPassed(ArgsParser.PRINT_AND_EXIT); if (printAndExit) { sensorsDataProvider.printAll(); return; } final String dbHost = argsParser.getString(DB_HOST_OPTION, "localhost"); final String user = argsParser.getString(DB_USER_OPTION); final String pwd = argsParser.getString(DB_PWD_OPTION); final int port = Integer.valueOf(argsParser.getString(APP_PORT_OPTION, PORT + "")); LOGGER.info("Connecting to {}, user {}, pwd: {}", dbHost, user, pwd); final DbDao dbDao = new DbDao(dbHost, user, pwd); new DataService(sensorsDataProvider, dbDao, 1000 * 60 * 5).start(); // Configure SSL. final SslContext sslCtx; if (SSL) { SelfSignedCertificate ssc = new SelfSignedCertificate(); sslCtx = SslContext.newServerContext(ssc.certificate(), ssc.privateKey()); } else { sslCtx = null; } // Configure the server. bossGroup = new NioEventLoopGroup(1); workerGroup = new NioEventLoopGroup(); ServerBootstrap b = new ServerBootstrap(); b.option(ChannelOption.SO_BACKLOG, 1024); b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .handler(new LoggingHandler(LogLevel.DEBUG)) .childHandler(new HomeStatsServerInitializer(sslCtx, dbDao, sensorsDataProvider)); Channel ch = b.bind(port).sync().channel(); System.err.println("Open your web browser and navigate to " + (SSL ? "https" : "http") + "://127.0.0.1:" + port + '/'); ch.closeFuture().sync(); } finally { if (bossGroup != null) { bossGroup.shutdownGracefully(); } if (workerGroup != null) { workerGroup.shutdownGracefully(); } } }
From source file:com.bloom.zerofs.rest.NettyServer.java
License:Open Source License
@Override public void start() throws InstantiationException { long startupBeginTime = System.currentTimeMillis(); try {/* www . j av a 2s. co m*/ logger.trace("Starting NettyServer deployment"); bossGroup = new NioEventLoopGroup(nettyConfig.nettyServerBossThreadCount); workerGroup = new NioEventLoopGroup(nettyConfig.nettyServerWorkerThreadCount); ServerBootstrap b = new ServerBootstrap(); // Netty creates a new instance of every class in the pipeline for every connection // i.e. if there are a 1000 active connections there will be a 1000 NettyMessageProcessor instances. b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .option(ChannelOption.SO_BACKLOG, nettyConfig.nettyServerSoBacklog) .handler(new LoggingHandler(LogLevel.DEBUG)).childHandler(channelInitializer); b.bind(nettyConfig.nettyServerPort).sync(); logger.info("NettyServer now listening on port {}", nettyConfig.nettyServerPort); } catch (InterruptedException e) { logger.error("NettyServer start await was interrupted", e); nettyMetrics.nettyServerStartError.inc(); throw new InstantiationException( "Netty server bind to port [" + nettyConfig.nettyServerPort + "] was interrupted"); } finally { long startupTime = System.currentTimeMillis() - startupBeginTime; logger.info("NettyServer start took {} ms", startupTime); nettyMetrics.nettyServerStartTimeInMs.update(startupTime); } }
From source file:com.digitalpetri.modbus.slave.ModbusTcpSlave.java
License:Apache License
public CompletableFuture<ModbusTcpSlave> bind(String host, int port) { CompletableFuture<ModbusTcpSlave> bindFuture = new CompletableFuture<>(); ServerBootstrap bootstrap = new ServerBootstrap(); ChannelInitializer<SocketChannel> initializer = new ChannelInitializer<SocketChannel>() { @Override// w ww .j a v a 2s .c o m protected void initChannel(SocketChannel channel) throws Exception { channelCounter.inc(); logger.info("channel initialized: {}", channel); channel.pipeline().addLast(new LoggingHandler(LogLevel.TRACE)); channel.pipeline() .addLast(new ModbusTcpCodec(new ModbusResponseEncoder(), new ModbusRequestDecoder())); channel.pipeline().addLast(new ModbusTcpSlaveHandler(ModbusTcpSlave.this)); channel.closeFuture().addListener(future -> channelCounter.dec()); } }; config.getBootstrapConsumer().accept(bootstrap); bootstrap.group(config.getEventLoop()).channel(NioServerSocketChannel.class) .handler(new LoggingHandler(LogLevel.DEBUG)).childHandler(initializer) .option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); bootstrap.bind(host, port).addListener((ChannelFuture future) -> { if (future.isSuccess()) { Channel channel = future.channel(); serverChannels.put(channel.localAddress(), channel); bindFuture.complete(ModbusTcpSlave.this); } else { bindFuture.completeExceptionally(future.cause()); } }); return bindFuture; }
From source file:com.flysoloing.learning.network.netty.socksproxy.SocksServerInitializer.java
License:Apache License
@Override public void initChannel(SocketChannel ch) throws Exception { ch.pipeline().addLast(new LoggingHandler(LogLevel.DEBUG), new SocksPortUnificationServerHandler(), SocksServerHandler.INSTANCE); }
From source file:com.github.ambry.rest.NettyServer.java
License:Open Source License
@Override public void start() throws InstantiationException { long startupBeginTime = System.currentTimeMillis(); try {/*from w w w . j a v a 2s . co m*/ logger.trace("Starting NettyServer deployment"); ServerBootstrap b = new ServerBootstrap(); // Netty creates a new instance of every class in the pipeline for every connection // i.e. if there are a 1000 active connections there will be a 1000 NettyMessageProcessor instances. b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .option(ChannelOption.SO_BACKLOG, nettyConfig.nettyServerSoBacklog) .handler(new LoggingHandler(LogLevel.DEBUG)).childHandler(channelInitializer); b.bind(nettyConfig.nettyServerPort).sync(); logger.info("NettyServer now listening on port {}", nettyConfig.nettyServerPort); } catch (InterruptedException e) { logger.error("NettyServer start await was interrupted", e); nettyMetrics.nettyServerStartError.inc(); throw new InstantiationException( "Netty server bind to port [" + nettyConfig.nettyServerPort + "] was interrupted"); } finally { long startupTime = System.currentTimeMillis() - startupBeginTime; logger.info("NettyServer start took {} ms", startupTime); nettyMetrics.nettyServerStartTimeInMs.update(startupTime); } }
From source file:com.github.kpavlov.jreactive8583.netty.pipeline.Iso8583ChannelInitializer.java
License:Apache License
protected ChannelHandler createLoggingHandler(G configuration) { return new IsoMessageLoggingHandler(LogLevel.DEBUG, configuration.logSensitiveData(), configuration.logFieldDescription(), configuration.getSensitiveDataFields()); }
From source file:com.heliosapm.shorthand.caster.broadcast.BroadcastListener.java
License:Open Source License
/** * Starts a listener on the passed socket address * @param isa The socket address to listen on * @param nic The network interface to listen on */// w w w. java 2 s . c o m public void startListener(InetSocketAddress isa, NetworkInterface nic) { Channel channel = null; if (isa.getAddress().isMulticastAddress()) { channel = bootstrap.group(group).channel(NioDatagramChannel.class) // .option(ChannelOption.SO_BROADCAST, true) .option(ChannelOption.IP_MULTICAST_ADDR, isa.getAddress()) .option(ChannelOption.SO_REUSEADDR, true) .option(ChannelOption.IP_MULTICAST_IF, NetUtil.LOOPBACK_IF) .handler(new ChannelInitializer<Channel>() { @Override protected void initChannel(Channel channel) throws Exception { ChannelPipeline pipeline = channel.pipeline(); pipeline.addLast(new LoggingHandler(BroadcastListener.class, LogLevel.DEBUG)); pipeline.addLast(router); } }).localAddress(isa).bind(isa.getPort()).syncUninterruptibly().channel(); ((NioDatagramChannel) channel).joinGroup(isa, NetUtil.LOOPBACK_IF).syncUninterruptibly(); //.bind(isa.getPort()).syncUninterruptibly().channel(); log("Bound to Multicast [%s]", isa); } else { channel = bootstrap.group(group).channel(NioDatagramChannel.class) .option(ChannelOption.SO_BROADCAST, true).handler(new ChannelInitializer<Channel>() { @Override protected void initChannel(Channel channel) throws Exception { ChannelPipeline pipeline = channel.pipeline(); pipeline.addLast(new LoggingHandler(BroadcastListener.class, LogLevel.DEBUG)); pipeline.addLast(router); } }).localAddress(isa).bind(isa).syncUninterruptibly().channel(); log("Bound to Broadcast UDP [%s]", isa); } boundChannels.add(channel); //.bind().syncUninterruptibly().channel(); boundChannels.add(channel); log("Started Broadcast Listener on [%s]", isa); }
From source file:com.hop.hhxx.example.socksproxy.SocksServerInitializer.java
License:Apache License
@Override public void initChannel(SocketChannel ch) throws Exception { ch.pipeline().addLast(new LoggingHandler(LogLevel.DEBUG), new SocksPortUnificationServerHandler(), io.netty.example.socksproxy.SocksServerHandler.INSTANCE); }