仅显示用户插入的日志

时间:2017-08-28 22:31:10

标签: scala apache-spark log4j

我正在使用slf4j来记录信息,使用spark和scala.How如何显示用户插入的消息作为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

这里有火花显示的例子

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)

任何帮助将不胜感激

1 个答案:

答案 0 :(得分:0)

import org.apache.log4j.{Level, Logger}
Logger.getLogger("org").setLevel(Level.OFF)