当前位置: 首页>>代码示例>>Java>>正文


Java LogLevel类代码示例

本文整理汇总了Java中io.netty.handler.logging.LogLevel的典型用法代码示例。如果您正苦于以下问题:Java LogLevel类的具体用法?Java LogLevel怎么用?Java LogLevel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LogLevel类属于io.netty.handler.logging包,在下文中一共展示了LogLevel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: NettyServer

import io.netty.handler.logging.LogLevel; //导入依赖的package包/类
private NettyServer(){
	pGroup = new NioEventLoopGroup();
	cGroup = new NioEventLoopGroup();
	serverBootstrap = new ServerBootstrap();
	serverBootstrap.group(pGroup, cGroup)
	 .channel(NioServerSocketChannel.class)
	 .option(ChannelOption.SO_BACKLOG, 1024)
	 //设置日志
	 .handler(new LoggingHandler(LogLevel.INFO))
	 .childHandler(new ChannelInitializer<SocketChannel>() {
		protected void initChannel(SocketChannel sc) throws Exception {
			sc.pipeline().addLast(MarshallingCodeCFactory.buildMarshallingDecoder());
			sc.pipeline().addLast(MarshallingCodeCFactory.buildMarshallingEncoder());
			sc.pipeline().addLast(new ReadTimeoutHandler(60));
			sc.pipeline().addLast(new NettyServerHandler());
		}
	});		
}
 
开发者ID:craware,项目名称:webapp-tyust,代码行数:19,代码来源:NettyServer.java

示例2: start

import io.netty.handler.logging.LogLevel; //导入依赖的package包/类
public void start(SlaveNode slaveNode) {
    if(slaveNode==null){
        throw new IllegalArgumentException("slaveNode is null");
    }
    EventLoopGroup bossGroup = new NioEventLoopGroup(CommonConstants.BOSS_GROUP_SIZE, new DefaultThreadFactory("boss", true));
    EventLoopGroup workerGroup = new NioEventLoopGroup(CommonConstants.WORKER_GROUP_SIZE, new DefaultThreadFactory("worker", true));
    try {
        ServerBootstrap b = new ServerBootstrap();
        b.option(ChannelOption.SO_BACKLOG, 1024);
        b.group(bossGroup, workerGroup)
         .channel(NioServerSocketChannel.class)
         .handler(new LoggingHandler(LogLevel.INFO))
         .childHandler(new SlaveServerInitializer());

        ChannelFuture future = b.bind(slaveNode.getPort()).sync();
        LOGGER.info("SlaveServer Startup at port:{}",slaveNode.getPort());

        // 等待服务端Socket关闭
        future.channel().closeFuture().sync();
    } catch (InterruptedException e) {
        LOGGER.error("InterruptedException:",e);
    } finally {
        bossGroup.shutdownGracefully();
        workerGroup.shutdownGracefully();
    }
}
 
开发者ID:all4you,项目名称:redant,代码行数:27,代码来源:SlaveServer.java

示例3: start

import io.netty.handler.logging.LogLevel; //导入依赖的package包/类
public void start() {
    EventLoopGroup bossGroup = new NioEventLoopGroup(CommonConstants.BOSS_GROUP_SIZE, new DefaultThreadFactory("boss", true));
    EventLoopGroup workerGroup = new NioEventLoopGroup(CommonConstants.WORKER_GROUP_SIZE, new DefaultThreadFactory("worker", true));
    try {
        ServerBootstrap b = new ServerBootstrap();
        b.option(ChannelOption.SO_BACKLOG, 1024);
        b.group(bossGroup, workerGroup)
         .channel(NioServerSocketChannel.class)
         .handler(new LoggingHandler(LogLevel.INFO))
         .childHandler(new MasterServerInitializer());

        ChannelFuture future = b.bind(CommonConstants.SERVER_PORT).sync();
        LOGGER.info("MasterServer Startup at port:{}",CommonConstants.SERVER_PORT);

        // 等待服务端Socket关闭
        future.channel().closeFuture().sync();
    } catch (InterruptedException e) {
        LOGGER.error("InterruptedException:",e);
    } finally {
        bossGroup.shutdownGracefully();
        workerGroup.shutdownGracefully();
    }
}
 
开发者ID:all4you,项目名称:redant,代码行数:24,代码来源:MasterServer.java

示例4: start

import io.netty.handler.logging.LogLevel; //导入依赖的package包/类
public void start() {
    EventLoopGroup bossGroup = new NioEventLoopGroup(CommonConstants.BOSS_GROUP_SIZE, new DefaultThreadFactory("boss", true));
    EventLoopGroup workerGroup = new NioEventLoopGroup(CommonConstants.WORKER_GROUP_SIZE, new DefaultThreadFactory("worker", true));
    try {
        ServerBootstrap b = new ServerBootstrap();
        b.option(ChannelOption.SO_BACKLOG, 1024);
        b.group(bossGroup, workerGroup)
         .channel(NioServerSocketChannel.class)
         .handler(new LoggingHandler(LogLevel.INFO))
         .childHandler(new ServerInitializer());

        ChannelFuture future = b.bind(CommonConstants.SERVER_PORT).sync();
        logger.info("NettyServer Startup at port:{}",CommonConstants.SERVER_PORT);

        // 等待服务端Socket关闭
        future.channel().closeFuture().sync();
    } catch (InterruptedException e) {
        logger.error("InterruptedException:",e);
    } finally {
        bossGroup.shutdownGracefully();
        workerGroup.shutdownGracefully();
    }
}
 
开发者ID:all4you,项目名称:redant,代码行数:24,代码来源:NettyServer.java

示例5: handlerAdded

import io.netty.handler.logging.LogLevel; //导入依赖的package包/类
@Override
public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
    LOGGER.info("{} : handlerAdded", connectionInfo);

    Http2Connection connection = new DefaultHttp2Connection(true);
    ChannelHandler http2ConnHandler = new HttpToHttp2ConnectionHandlerBuilder()
            .frameListener(new DelegatingDecompressorFrameListener(
                    connection,
                    new InboundHttp2ToHttpAdapterBuilder(connection)
                            .maxContentLength(master.config().getMaxContentLength())
                            .propagateSettings(true)
                            .build()))
            .connection(connection)
            .frameLogger(new Http2FrameLogger(LogLevel.DEBUG))
            .build();
    ctx.pipeline()
       .addBefore(ctx.name(), null, http2ConnHandler)
       .addBefore(ctx.name(), null, new Http2Handler());
}
 
开发者ID:chhsiao90,项目名称:nitmproxy,代码行数:20,代码来源:Http2FrontendHandler.java

示例6: handlerAdded

import io.netty.handler.logging.LogLevel; //导入依赖的package包/类
@Override
public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
    LOGGER.info("{} : handlerAdded", connectionInfo);

    Http2Connection connection = new DefaultHttp2Connection(false);
    ChannelHandler http2ConnHandler = new HttpToHttp2ConnectionHandlerBuilder()
            .frameListener(new DelegatingDecompressorFrameListener(
                    connection,
                    new InboundHttp2ToHttpAdapterBuilder(connection)
                            .maxContentLength(master.config().getMaxContentLength())
                            .propagateSettings(true)
                            .build()))
            .frameLogger(new Http2FrameLogger(LogLevel.DEBUG))
            .connection(connection)
            .build();
    ctx.pipeline()
       .addBefore(ctx.name(), null, http2ConnHandler)
       .addBefore(ctx.name(), null, new Http2Handler());
}
 
开发者ID:chhsiao90,项目名称:nitmproxy,代码行数:20,代码来源:Http2BackendHandler.java

示例7: run

import io.netty.handler.logging.LogLevel; //导入依赖的package包/类
public void run() {
    try {
        // Configure the server.
        EventLoopGroup group = new NioEventLoopGroup();
        try {
            ServerBootstrap b = new ServerBootstrap();
            b.option(ChannelOption.SO_BACKLOG, 1024);
            b.group(group)
                    .channel(NioServerSocketChannel.class)
                    .handler(new LoggingHandler(LogLevel.INFO))
                    .childHandler(new Http2ServerInitializer(mSslCtx));

            sServerChannel = b.bind(PORT).sync().channel();
            Log.i(TAG, "Netty HTTP/2 server started on " + getServerUrl());
            sBlock.open();
            sServerChannel.closeFuture().sync();
        } finally {
            group.shutdownGracefully();
        }
        Log.i(TAG, "Stopped Http2TestServerRunnable!");
    } catch (Exception e) {
        Log.e(TAG, e.toString());
    }
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:25,代码来源:Http2TestServer.java

示例8: start

import io.netty.handler.logging.LogLevel; //导入依赖的package包/类
@PostConstruct
public void start() {
    new Thread(() -> {
        logger.info("HttpProxyServer started on port: {}", port);
        EventLoopGroup bossGroup = new NioEventLoopGroup(1);
        EventLoopGroup workerGroup = new NioEventLoopGroup();
        try {
            ServerBootstrap b = new ServerBootstrap();
            b.group(bossGroup, workerGroup)
                    .channel(NioServerSocketChannel.class)
                    .handler(new LoggingHandler(LogLevel.DEBUG))
                    .childHandler(channelInitializer)
                    .bind(port).sync().channel().closeFuture().sync();
        } catch (InterruptedException e) {
            logger.error("shit happens", e);
        } finally {
            bossGroup.shutdownGracefully();
            workerGroup.shutdownGracefully();
        }
    }).start();
}
 
开发者ID:shuaicj,项目名称:http-proxy-netty,代码行数:22,代码来源:HttpProxyServer.java

示例9: start

import io.netty.handler.logging.LogLevel; //导入依赖的package包/类
@Override
public synchronized void start() {
    bossGroup = new NioEventLoopGroup(); // (1)
    workerGroup = new NioEventLoopGroup();
    try {
        b = new ServerBootstrap(); // (2)
        b.group(bossGroup, workerGroup)
                .channel(NioServerSocketChannel.class)
                .option(ChannelOption.SO_BACKLOG, 100)
                .handler(new LoggingHandler(LogLevel.INFO))
                .childHandler(new SocketServerChannelInitializer(heartTime,socketService,applicationContext));
        // Bind and start to accept incoming connections.
        b.bind(port);

        logger.info("socket: "+port+" starting....");
        // Wait until the server socket is closed.
        // In this example, this does not happen, but you can do that to gracefully
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:1991wangliang,项目名称:sds,代码行数:22,代码来源:NettyServerServiceImpl.java

示例10: initChannel

import io.netty.handler.logging.LogLevel; //导入依赖的package包/类
@Override
    public void initChannel(SocketChannel ch) throws Exception {
        // Create a default pipeline implementation.
        ChannelPipeline p = ch.pipeline();

        p.addLast("log", new LoggingHandler(LogLevel.INFO));
        // Enable HTTPS if necessary.
/*        if (ssl) {
            SSLEngine engine =
                SecureChatSslContextFactory.getClientContext().createSSLEngine();
            engine.setUseClientMode(true);

            p.addLast("ssl", new SslHandler(engine));
        }*/

        p.addLast("codec", new HttpClientCodec());

        // Remove the following line if you don't want automatic content decompression.
        p.addLast("inflater", new HttpContentDecompressor());

        // Uncomment the following line if you don't want to handle HttpChunks.
        //p.addLast("aggregator", new HttpObjectAggregator(1048576));

        p.addLast("handler", new HttpSnoopClientHandler());
    }
 
开发者ID:eBay,项目名称:ServiceCOLDCache,代码行数:26,代码来源:HttpSnoopClientInitializer.java

示例11: bind

import io.netty.handler.logging.LogLevel; //导入依赖的package包/类
public void bind(int port) throws Exception {
	EventLoopGroup bossGroup = new NioEventLoopGroup();
	EventLoopGroup workerGroup = new NioEventLoopGroup();
	try{
		ServerBootstrap b = new ServerBootstrap();
		b.group(bossGroup, workerGroup)
		.channel(NioServerSocketChannel.class)
		.option(ChannelOption.SO_BACKLOG, 1024)
		.handler(new LoggingHandler(LogLevel.INFO))
		.childHandler(new ChildChannelHandler());
		// 绑定端口 同步等待成功
		ChannelFuture f = b.bind(port).sync();
		// 等待服务端监听端口关闭
		f.channel().closeFuture().sync ();
	}finally{
		//优雅的退出 释放线程池资源
		bossGroup.shutdownGracefully();
		workerGroup.shutdownGracefully();
	}
	
}
 
开发者ID:hdcuican,项目名称:java_learn,代码行数:22,代码来源:SubReqServer.java

示例12: start

import io.netty.handler.logging.LogLevel; //导入依赖的package包/类
@Override
public void start() {
	ServerBootstrap bootstrap = new ServerBootstrap();
	bootstrap.group(bossGroup, workerGroup)
			.channel(NioServerSocketChannel.class)
			.childHandler(new ChannelInitializer<SocketChannel>() {
				protected void initChannel(SocketChannel ch) throws Exception {
					ch.pipeline()
							.addLast(new LoggingHandler(LogLevel.INFO))
							.addLast(new ProtocolDecoder(10 * 1024 * 1024))
							.addLast(new ProtocolEncoder())
							.addLast(new RpcServerHandler(serviceImpl))
					;
				}
			});
	try {
		ChannelFuture sync = bootstrap.bind(port).sync();
		registerService();
		LOGGER.info("Server Started At {}", port);
		started = true;
		this.channel = sync.channel();
	} catch (InterruptedException e) {
		e.printStackTrace();
	}
}
 
开发者ID:liuzhengyang,项目名称:simple-rpc,代码行数:26,代码来源:ServerImpl.java

示例13: start

import io.netty.handler.logging.LogLevel; //导入依赖的package包/类
public void start(int port, ChannelHandler channelInitializer, int bossThreads, int workThreads)
		throws Exception {
	bossGroup = new NioEventLoopGroup(bossThreads);
	workerGroup = new NioEventLoopGroup(workThreads);
	try {
		ServerBootstrap b = new ServerBootstrap();
		b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
				.option(ChannelOption.SO_BACKLOG, Integer.parseInt(System.getProperty("so.BACKLOG", "100")))
				// .option(ChannelOption.SO_KEEPALIVE,
				// Boolean.parseBoolean(System.getProperty("so.KEEPALIVE",
				// "true")))
				// .option(ChannelOption.SO_LINGER,
				// Integer.parseInt(System.getProperty("so.LINGER", "0")))
				.option(ChannelOption.SO_REUSEADDR,
						Boolean.parseBoolean(System.getProperty("so.REUSEADDR", "true")))
				 .handler(new LoggingHandler(LogLevel.DEBUG))
				.childHandler(channelInitializer);
		f = b.bind(port).sync();
		logger.info("Server started and listen on port:{}", port);
		f.channel().closeFuture().sync();
	} finally {
		close_();
	}
}
 
开发者ID:houkx,项目名称:nettythrift,代码行数:25,代码来源:CommonServer.java

示例14: NetworkServiceImpl

import io.netty.handler.logging.LogLevel; //导入依赖的package包/类
NetworkServiceImpl(final NetworkServiceBuilder builder) {
    int bossLoopGroupCount = builder.getBossLoopGroupCount();
    int workerLoopGroupCount = builder.getWorkerLoopGroupCount();
    this.port = builder.getPort();

    bossGroup = new NioEventLoopGroup(bossLoopGroupCount);
    workerGroup = new NioEventLoopGroup(workerLoopGroupCount);

    bootstrap = new ServerBootstrap();
    bootstrap.group(bossGroup, workerGroup);
    bootstrap.channel(NioServerSocketChannel.class);
    bootstrap.option(ChannelOption.SO_BACKLOG, 1024);
    bootstrap.childOption(ChannelOption.TCP_NODELAY, true);
    bootstrap.childOption(ChannelOption.SO_RCVBUF, 128 * 1024);
    bootstrap.childOption(ChannelOption.SO_SNDBUF, 128 * 1024);

    bootstrap.handler(new LoggingHandler(LogLevel.DEBUG));
    if (builder.isWebSocket()) {
        bootstrap.childHandler(new WebSocketHandler(builder));
    } else {
        bootstrap.childHandler(new SocketHandler(builder));
    }
}
 
开发者ID:beimi,项目名称:ServerCore,代码行数:24,代码来源:NetworkServiceImpl.java

示例15: start

import io.netty.handler.logging.LogLevel; //导入依赖的package包/类
@Override
public void start() {
    ServerBootstrap bootstrap = new ServerBootstrap();
    bootstrap.group(boss, worker)
            .channel(NioServerSocketChannel.class)
            .handler(new LoggingHandler(LogLevel.DEBUG))
            .childOption(ChannelOption.SO_KEEPALIVE, true)
            .childHandler(new ChannelInitializer<SocketChannel>() {
                @Override
                protected void initChannel(SocketChannel ch) throws Exception {
                    ch.pipeline().addLast(new PacketDecoder());
                    ch.pipeline().addLast(new PacketEncoder());
                    ch.pipeline().addLast(businessGroup, new Dispatcher(ServerEntry.this));
                }
            });
    try {
        bootstrap.bind(host, port).sync();
    } catch (InterruptedException e) {
        stop();
    }
}
 
开发者ID:archerfeel,项目名称:awacs,代码行数:22,代码来源:ServerEntry.java


注:本文中的io.netty.handler.logging.LogLevel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。