【发布时间】:2017-08-28 22:31:09
【问题描述】:
我正在使用 slf4j 记录信息,使用 spark 和 scala。如何将用户插入的消息显示为 logg 而不是整个 spark 日志文件,这里是 log4j.properties
# Here we have defined root logger
log4j.rootLogger=ALL,R
#Direct log messages to file
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=./logging.log
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L- %m%n
这里是 spark 显示的示例
2017-08-29 09:19:03 TRACE NioEventLoop:46- Instrumented an optimized java.util.Set into: sun.nio.ch.WindowsSelectorImpl@7eac9008
2017-08-29 09:19:03 TRACE NioEventLoop:46- Instrumented an optimized java.util.Set into: sun.nio.ch.WindowsSelectorImpl@4116aac9
2017-08-29 09:19:03 TRACE NioEventLoop:46- Instrumented an optimized java.util.Set into: sun.nio.ch.WindowsSelectorImpl@62ddbd7e
2017-08-29 09:19:03 DEBUG PooledByteBufAllocator:76- -Dio.netty.allocator.numHeapArenas: 16
2017-08-29 09:19:03 DEBUG PooledByteBufAllocator:76- -Dio.netty.allocator.numDirectArenas: 16
2017-08-29 09:19:03 DEBUG PooledByteBufAllocator:76- -Dio.netty.allocator.pageSize: 8192
2017-08-29 09:19:03 DEBUG PooledByteBufAllocator:76- -Dio.netty.allocator.maxOrder: 11
2017-08-29 09:19:03 DEBUG PooledByteBufAllocator:76- -Dio.netty.allocator.chunkSize: 16777216
2017-08-29 09:19:03 DEBUG PooledByteBufAllocator:76- -Dio.netty.allocator.tinyCacheSize: 512
2017-08-29 09:19:03 DEBUG PooledByteBufAllocator:76- -Dio.netty.allocator.smallCacheSize: 256
2017-08-29 09:19:03 DEBUG PooledByteBufAllocator:76- -Dio.netty.allocator.normalCacheSize: 64
2017-08-29 09:19:03 DEBUG PooledByteBufAllocator:76- -Dio.netty.allocator.maxCachedBufferCapacity: 32768
2017-08-29 09:19:03 DEBUG PooledByteBufAllocator:76- -Dio.netty.allocator.cacheTrimInterval: 8192
2017-08-29 09:19:03 TRACE NioEventLoop:46- Instrumented an optimized java.util.Set into: sun.nio.ch.WindowsSelectorImpl@ae13544
2017-08-29 09:19:03 TRACE NioEventLoop:46- Instrumented an optimized java.util.Set into: sun.nio.ch.WindowsSelectorImpl@3d34d211
2017-08-29 09:19:03 TRACE NioEventLoop:46- Instrumented an optimized java.util.Set into: sun.nio.ch.WindowsSelectorImpl@7dc0f706
2017-08-29 09:19:03 TRACE NioEventLoop:46- Instrumented an optimized java.util.Set into: sun.nio.ch.WindowsSelectorImpl@4009e306
2017-08-29 09:19:03 TRACE NioEventLoop:46- Instrumented an optimized java.util.Set into: sun.nio.ch.WindowsSelectorImpl@43c1b556
2017-08-29 09:19:03 TRACE NioEventLoop:46- Instrumented an optimized java.util.Set into: sun.nio.ch.WindowsSelectorImpl@587e5365
2017-08-29 09:19:03 TRACE NioEventLoop:46- Instrumented an optimized java.util.Set into: sun.nio.ch.WindowsSelectorImpl@22fcf7ab
2017-08-29 09:19:03 TRACE NioEventLoop:46- Instrumented an optimized java.util.Set into: sun.nio.ch.WindowsSelectorImpl@2de23121
2017-08-29 09:19:03 DEBUG ThreadLocalRandom:71- -Dio.netty.initialSeedUniquifier: 0x7436749e963a1485 (took 1 ms)
2017-08-29 09:19:03 DEBUG ByteBufUtil:76- -Dio.netty.allocator.type: unpooled
2017-08-29 09:19:03 DEBUG ByteBufUtil:76- -Dio.netty.t
i want to see only message inserted by user
这里是scalla代码
import org.apache.log4j.{Level, Logger}
Logger.getLogger("org").setLevel(Level.OFF)
任何帮助将不胜感激
【问题讨论】:
标签: scala apache-spark log4j