我们使用PDFBox的做一些PDF阅读和操作。 但分析过程中,我得到了一堆像这样的消息:
Changing font on <m> from <Arial Bold> to the default font
现在,我怎么可以禁用这些? 因为这样的消息被输出在输入的每个字符是否字体被嵌入,因此,日志文件变得相当不可用。
现在改变总日志级别是不是一种选择,因为我需要从其他组件的语句。
我使用Tomcat 5.5,log4j的1.2.16和PDFBOX,应用1.6.0
这里是我的log4j的配置文件:
# Root logger option
log4j.rootLogger=INFO, file, stdout
# Direct log messages to a log file
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
#log4j.appender.file.File=/home/PDF/WS/PDF.log
log4j.appender.file.File=C:\\loging.log
log4j.appender.file.MaxFileSize=5MB
log4j.appender.file.MaxBackupIndex=1
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %-5p [%c{2}]: %m%n
# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %-5p [%c{2}]: %m%n
编辑
修改我的log4j的文件后,这是它的外观:
# Root logger option
log4j.rootLogger=INFO, file, stdout
log4j.rootLogger.org.apache.pdfbox=ERROR
# Direct log messages to a log file
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
#log4j.appender.file.File=/home/PDF/WS/PDF.log
log4j.appender.file.File=C:\\loging.log
log4j.appender.file.MaxFileSize=5MB
log4j.appender.file.MaxBackupIndex=1
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %-5p [%c{2}]: %m%n
# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %-5p [%c{2}]: %m%n
无论身在何处,我把log4j.rootLogger.org.apache.pdfbox=ERROR
行,误差仍保持在日志文件中弹出这样的:
2012-07-16 15:36:46,652 WARN [font.PDSimpleFont]: Changing font on <r> from <Arial Bold> to the default font
2012-07-16 15:36:46,652 WARN [font.PDSimpleFont]: Changing font on <o> from <Arial Bold> to the default font
2012-07-16 15:36:46,667 WARN [font.PDSimpleFont]: Changing font on <c> from <Arial Bold> to the default font
2012-07-16 15:36:46,667 WARN [font.PDSimpleFont]: Changing font on <e> from <Arial Bold> to the default font
2012-07-16 15:36:46,667 WARN [font.PDSimpleFont]: Changing font on <s> from <Arial Bold> to the default font
2012-07-16 15:36:46,667 WARN [font.PDSimpleFont]: Changing font on <u> from <Arial Bold> to the default font
2012-07-16 15:36:46,667 WARN [font.PDSimpleFont]: Changing font on < > from <Arial Bold> to the default font
2012-07-16 15:36:46,667 WARN [font.PDSimpleFont]: Changing font on <P> from <Arial Bold> to the default font
编辑2
协商后的log4j:包特定的日志记录 ,我发现了正确的语法:
log4j.logger.org.apache.pdfbox=ERROR