Hello all i have a simple task I am using netty for some server-client tasks. My problem is that netty produces a huge amount of debugging info that i don't want in my app. Does anyone know how to turn this off? I really don't need to see this output.
Here is an example of the output:
20:38:55.663 [main] DEBUG io.netty.util.internal.logging.InternalLoggerFactory - Using SLF4J as the default logging framework
20:38:55.667 [main] DEBUG io.netty.channel.MultithreadEventLoopGroup - -Dio.netty.eventLoopThreads: 48
20:38:55.690 [main] DEBUG io.netty.util.internal.InternalThreadLocalMap - -Dio.netty.threadLocalMap.stringBuilder.initialSize: 1024
20:38:55.690 [main] DEBUG io.netty.util.internal.InternalThreadLocalMap - -Dio.netty.threadLocalMap.stringBuilder.maxSize: 4096
20:38:55.710 [main] DEBUG io.netty.util.internal.PlatformDependent0 - -Dio.netty.noUnsafe: false
20:38:55.710 [main] DEBUG io.netty.util.internal.PlatformDependent0 - Java version: 11
20:38:55.711 [main] DEBUG io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.theUnsafe: available
20:38:55.712 [main] DEBUG io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.copyMemory: available
20:38:55.712 [main] DEBUG io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.storeFence: available
20:38:55.713 [main] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.Buffer.address: available
20:38:55.713 [main] DEBUG io.netty.util.internal.PlatformDependent0 - direct buffer constructor: unavailable: Reflective setAccessible(true) disabled
20:38:55.714 [main] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.Bits.unaligned: available, true
20:38:55.714 [main] DEBUG io.netty.util.internal.PlatformDependent0 - jdk.internal.misc.Unsafe.allocateUninitializedArray(int): unavailable: class io.netty.util.internal.PlatformDependent0$7 cannot access class jdk.internal.misc.Unsafe (in module java.base) because module java.base does not export jdk.internal.misc to unnamed module @6e15fe2
20:38:55.715 [main] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.DirectByteBuffer.<init>(long, int): unavailable
20:38:55.715 [main] DEBUG io.netty.util.internal.PlatformDependent - sun.misc.Unsafe: available
20:38:55.723 [main] DEBUG io.netty.util.internal.PlatformDependent - maxDirectMemory: 17121148928 bytes (maybe)
20:38:55.724 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.tmpdir: C:\Temp (java.io.tmpdir)
20:38:55.724 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.bitMode: 64 (sun.arch.data.model)
20:38:55.724 [main] DEBUG io.netty.util.internal.PlatformDependent - Platform: Windows
20:38:55.725 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.maxDirectMemory: -1 bytes
20:38:55.725 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.uninitializedArrayAllocationThreshold: -1
20:38:55.726 [main] DEBUG io.netty.util.internal.CleanerJava9 - java.nio.ByteBuffer.cleaner(): available
20:38:55.726 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.noPreferDirect: false
I guess I want something similar to this (i am not sure) but for SLF4J
import java.util.logging.Level;
import java.util.logging.Logger;
Logger.getLogger("io.netty").setLevel(Level.OFF);
i found the solution here is the magic:
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.Logger;
LoggerContext loggerContext = (LoggerContext)LoggerFactory.getILoggerFactory();
Logger rootLogger = loggerContext.getLogger("io.netty");
rootLogger.setLevel(ch.qos.logback.classic.Level.OFF);
This can be done also via logger file:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- Define a console appender -->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<!-- Disable logging for io.netty -->
<logger name="io.netty" level="OFF"/>
<!-- Root logger settings -->
<root level="INFO">
<appender-ref ref="CONSOLE"/>
</root>
</configuration>