일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
- scala 2.10
- avo
- Elasticsearch
- springboot
- spring-kafka
- kafka interactive query
- Slick
- 한빛미디어
- 카프카
- kafkastream
- statestore
- spring-batch
- reactive
- kafka streams
- aws
- spring-cloud-stream
- enablekafkastreams
- Elk
- Spring
- scala
- coursera
- Logstash
- kafkastreams
- confluent
- RabbitMQ
- gradle
- play framework
- Kafka
- 플레이 프레임워크
- schema registry
- Today
- Total
b
netty학습을 위한 logback 설정 본문
Netty를 학습하기 위해서 Debug 레벨로 로그를 보고 싶음.
모든 튜토리얼에서 처음에 나오는 클래스인 ServerBootstrap ( https://git.io/fjeuN ) 를 살펴보면 InternalLoggerFactory 클래스를 이용해서 인스턴스를 획득하는 것을 볼 수 있다. 해당 클래스는 abstract class 이고 다양한 로그 라이브러를 지원하고 있음을 알 수 있다.
그 중에서 slf4j - logback 콤보를 이용하기 위해 아래 디펜던시를 추가한다.
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
그리고 classpath에 아래와 같은 기본적인 logback.xml 을 설정한다
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="console"/>
</root>
</configuration>
아래와 같은 콘솔 로그를 확인 할 수 있다.
io.netty.util.internal.logging.InternalLoggerFactory - Using SLF4J as the default logging framework io.netty.channel.MultithreadEventLoopGroup - -Dio.netty.eventLoopThreads: 24 io.netty.util.internal.PlatformDependent0 - -Dio.netty.noUnsafe: false io.netty.util.internal.PlatformDependent0 - Java version: 8 io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.theUnsafe: available io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.copyMemory: available io.netty.util.internal.PlatformDependent0 - java.nio.Buffer.address: available io.netty.util.internal.PlatformDependent0 - direct buffer constructor: available io.netty.util.internal.PlatformDependent0 - java.nio.Bits.unaligned: available, true io.netty.util.internal.PlatformDependent0 - jdk.internal.misc.Unsafe.allocateUninitializedArray(int): unavailable prior to Java9 io.netty.util.internal.PlatformDependent0 - java.nio.DirectByteBuffer.(long, int): available io.netty.util.internal.PlatformDependent - sun.misc.Unsafe: available io.netty.util.internal.PlatformDependent - -Dio.netty.tmpdir: /var/folders/sr/grtv_wmn3wj092488tqh7slr0000gn/T (java.io.tmpdir) io.netty.util.internal.PlatformDependent - -Dio.netty.bitMode: 64 (sun.arch.data.model) io.netty.util.internal.PlatformDependent - -Dio.netty.noPreferDirect: false io.netty.util.internal.PlatformDependent - -Dio.netty.maxDirectMemory: 3817865216 bytes io.netty.util.internal.PlatformDependent - -Dio.netty.uninitializedArrayAllocationThreshold: -1 io.netty.util.internal.CleanerJava6 - java.nio.ByteBuffer.cleaner(): available io.netty.channel.nio.NioEventLoop - -Dio.netty.noKeySetOptimization: false io.netty.channel.nio.NioEventLoop - -Dio.netty.selectorAutoRebuildThreshold: 512 io.netty.util.internal.PlatformDependent - org.jctools-core.MpscChunkedArrayQueue: available io.netty.channel.DefaultChannelId - -Dio.netty.processId: 78164 (auto-detected) io.netty.util.NetUtil - -Djava.net.preferIPv4Stack: false io.netty.util.NetUtil - -Djava.net.preferIPv6Addresses: false io.netty.util.NetUtil - Loopback interface: lo0 (lo0, 0:0:0:0:0:0:0:1%lo0) io.netty.util.NetUtil - Failed to get SOMAXCONN from sysctl and file /proc/sys/net/core/somaxconn. Default: 128 io.netty.channel.DefaultChannelId - -Dio.netty.machineId: xx:1c:xx:ff:fe:00:00:09 (auto-detected) io.netty.util.ResourceLeakDetector - -Dio.netty.leakDetection.level: simple io.netty.util.ResourceLeakDetector - -Dio.netty.leakDetection.maxRecords: 4 io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.numHeapArenas: 24 io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.numDirectArenas: 24 io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.pageSize: 8192 io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxOrder: 11 io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.chunkSize: 16777216 io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.tinyCacheSize: 512 io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.smallCacheSize: 256 io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.normalCacheSize: 64 io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxCachedBufferCapacity: 32768 io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.cacheTrimInterval: 8192 io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.useCacheForAllThreads: true io.netty.buffer.ByteBufUtil - -Dio.netty.allocator.type: pooled io.netty.buffer.ByteBufUtil - -Dio.netty.threadLocalDirectBufferSize: 65536 io.netty.buffer.ByteBufUtil - -Dio.netty.maxThreadLocalCharBufferSize: 16384
1라인 : slf4j 를 로깅 프레임웍으로 쓰고 있는 것을 확인
2라인 : 내 맥북의 사용가능 CPU가 12개 여서 24 ( https://git.io/fjez0 )
주의) 혹시나 java.lang.ClassNotFoundException: jdk.internal.misc.Unsafe 오류가 보인다면 Netty 4.11 을 사용하고 있는지 확인하고 4.12+ 로 버전 변경 한다 ( https://github.com/netty/netty/issues/6901 )