satoshinm / WebSandboxMC

Bukkit plugin providing a web-based interface with an interactive WebGL 3D preview or glimpse of your server 🕷⏳📦 ⛺
https://www.spigotmc.org/resources/websandboxmc.39415/
MIT License
19 stars 5 forks source link

Log spam when clients connect #84

Closed satoshinm closed 7 years ago

satoshinm commented 7 years ago
2017/05/31 00:14:05 [INFO] [id: 0xf4366b94, L:/0:0:0:0:0:0:0:0:4081] RECEIVED: [id: 0x3ef2cda9, L:/127.0.0.1:4081 - R:/127.0.0.1:53340]
2017/05/31 00:14:06 [INFO] [id: 0xf4366b94, L:/0:0:0:0:0:0:0:0:4081] RECEIVED: [id: 0xd86cd495, L:/127.0.0.1:4081 - R:/127.0.0.1:53342]
2017/05/31 00:14:07 [INFO] [id: 0xf4366b94, L:/0:0:0:0:0:0:0:0:4081] RECEIVED: [id: 0xb0fdcace, L:/127.0.0.1:4081 - R:/127.0.0.1:53344]
2017/05/31 00:38:56 [INFO] [id: 0xf4366b94, L:/0:0:0:0:0:0:0:0:4081] RECEIVED: [id: 0x0b00c850, L:/127.0.0.1:4081 - R:/127.0.0.1:53358]

Can this be disabled? Seems maybe to be coming from within Netty?


Added netty_log_info boolean, default false to use Netty log level DEBUG, can be set to true to re-enable INFO level

satoshinm commented 7 years ago
io/github/satoshinm/WebSandboxMC/dep/io/netty/handler/logging/LoggingHandler.java
166:         this.logger.log(this.internalLevel, this.format(ctx, "RECEIVED", msg));

and/or here:

resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java
907:                    logger.debug("{} RECEIVED: [{}: {}], {}", ch, queryId, res.sender(), res);

https://github.com/netty/netty/blob/270e9d66c5a422b007312cb282097a8cc9b1b091/resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java#L933-L935

                if (logger.isDebugEnabled()) {
                    logger.debug("{} RECEIVED: [{}: {}], {}", ch, queryId, res.sender(), res);
                }

why is isDebugEnabled()?

satoshinm commented 7 years ago

https://stackoverflow.com/questions/20734847/how-to-disable-logs-in-netty-4 suggests:

Logger.getLogger("io.netty").setLevel(Level.OFF);

Note this is not the only logging:

20:19:02 [INFO] [id: 0x1137c456] REGISTERED
20:19:02 [INFO] [id: 0x1137c456] BIND: 0.0.0.0/0.0.0.0:4081
20:19:02 [INFO] [WebSandboxMC] Open your web browser and navigate to http://127.0.0.1:4081/ or http://localhost:4081/
20:19:02 [INFO] [id: 0x1137c456, L:/0:0:0:0:0:0:0:0:4081] ACTIVE

LoggingHandler.java has many logs:

   public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
      if(this.logger.isEnabled(this.internalLevel)) {^M
         this.logger.log(this.internalLevel, this.format(ctx, "REGISTERED"));^M
      }^M
^M
      ctx.fireChannelRegistered();^M
   }

   public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
      if(this.logger.isEnabled(this.internalLevel)) {^M
         this.logger.log(this.internalLevel, this.format(ctx, "RECEIVED", msg));^M
      }^M
^M
      ctx.fireChannelRead(msg);^M
   }

Why isEnabled(this.internalLevel)? https://stackoverflow.com/questions/9852473/how-to-configure-netty-logger-factory-in-order-to-see-the-output-of-logginghandl#14019881 says:

InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory()); should be executed right on the entry point of your program. Sometimes this "entry point" may be very hard to determine.
satoshinm commented 7 years ago

WebSocketServerThread.java sets a LoggingHandler with LogLevel.INFO:

                b.group(bossGroup, workerGroup)
                        .channel(NioServerSocketChannel.class)
                        .handler(new LoggingHandler(LogLevel.INFO))
                        .childHandler(new WebSocketServerInitializer(sslCtx, this,
                                settings.pluginDataFolder));

the default level is DEBUG, omit it to avoid logging as INFO?

satoshinm commented 7 years ago
--- a/src/main/java/io/github/satoshinm/WebSandboxMC/ws/WebSocketServerThread.java
+++ b/src/main/java/io/github/satoshinm/WebSandboxMC/ws/WebSocketServerThread.java
@@ -109,7 +109,7 @@ public final class WebSocketServerThread extends Thread {
                 ServerBootstrap b = new ServerBootstrap();
                 b.group(bossGroup, workerGroup)
                         .channel(NioServerSocketChannel.class)
-                        .handler(new LoggingHandler(LogLevel.INFO))
+                        .handler(new LoggingHandler())
                         .childHandler(new WebSocketServerInitializer(sslCtx, this,
                                 settings.pluginDataFolder));

works to suppress the logging, but note there isn't any other logging for when a new web client connects, so may want to expand on this first.