我們使用PDFBox來執行一些PDF閱讀和操作。但是在解析過程中,我收到了一堆這樣的消息:在PDFBox上禁用日誌記錄
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
EDIT 2
諮詢log4j: package-specific logging後,我發現了正確的語法:
log4j.logger.org.apache.pdfbox=ERROR
見http://stackoverflow.com/questions/728295/creating-multiple-log-files-of-different-content-with-log4j的 – Kennet 2012-07-13 08:21:26
可能重複[調整爲Apache通用日誌記錄級別?( http://stackoverflow.com/que smissions/5009658/adjust-logging-level-for-apache-commons-logging) – 2015-07-06 13:43:03
這個日誌記錄不僅令人煩惱,它還是一個主要的性能殺手... – 2015-07-06 13:46:05