Add LoggingHandler to ServerSocketChannel's pipeline
This commit is contained in:
parent
f29b6ae29a
commit
3b8de9f133
@ -19,6 +19,7 @@ import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.ServerChannelBootstrap;
|
||||
import io.netty.channel.socket.ServerSocketChannel;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import io.netty.channel.socket.nio.NioEventLoop;
|
||||
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
||||
@ -47,6 +48,12 @@ public class EchoServer {
|
||||
.option(ChannelOption.SO_BACKLOG, 100)
|
||||
.localAddress(new InetSocketAddress(port))
|
||||
.childOption(ChannelOption.TCP_NODELAY, true)
|
||||
.initializer(new ChannelInitializer<ServerSocketChannel>() {
|
||||
@Override
|
||||
public void initChannel(ServerSocketChannel ch) throws Exception {
|
||||
ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO));
|
||||
}
|
||||
})
|
||||
.childInitializer(new ChannelInitializer<SocketChannel>() {
|
||||
@Override
|
||||
public void initChannel(SocketChannel ch) throws Exception {
|
||||
|
Loading…
Reference in New Issue
Block a user