我找不到一种方法来阻止我在 psring 启动应用程序中使用的 PDFBox 发出的警告。例如:
2019-10-01 16:53:51.021 WARN 24564 --- [nio-8443-exec-2] o.a.pdfbox.pdmodel.font.PDType0Font : No Unicode mapping for CID+4 (4) in font Calibri-Bold
2019-10-01 16:53:51.022 WARN 24564 --- [nio-8443-exec-2] o.a.pdfbox.pdmodel.font.PDCIDFontType2 : Failed to find a character mapping for 4 in Calibri-Bold
2019-10-01 16:53:51.022 WARN 24564 --- [nio-8443-exec-2] o.a.pdfbox.pdmodel.font.PDCIDFontType2 : Failed to find a character mapping for 4 in Calibri-Bold
我尝试过:在应用程序文件中:
static {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog");
java.util.logging.Logger.getLogger("org.apache.pdfbox").setLevel(java.util.logging.Level.OFF);
String[] loggers = {
"org.apache.pdfbox.util.PDFStreamEngine",
"org.apache.pdfbox.pdmodel.font.PDSimpleFont",
"org.apache.pdfbox.pdmodel.font.PDFont",
"org.apache.pdfbox.pdmodel.font.FontManager",
"org.apache.pdfbox.pdfparser.PDFObjectStreamParser",
"o.a.pdfbox.pdmodel.font.PDCIDFontType2",
"org.apache.pdfbox.pdmodel.font.PDCIDFontType2",
"o.a.pdfbox.pdmodel.font.PDType0Font",
"org.apache.pdfbox.pdmodel.font.PDType0Font",
"org.apache.pdfbox.pdmodel.font.PDType1Font"
};
for (String logger: loggers) {
org.apache.log4j.Logger logpdfengine = org.apache.log4j.Logger
.getLogger(logger);
logpdfengine.setLevel(org.apache.log4j.Level.OFF);
}
}
作为运行jar时的参数:
-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.NoOpLog
-Dorg.slf4j.simpleLogger.defaultLogLevel=off
在 PDFBox 代码中,使用以下命令设置日志:
(import org.apache.commons.logging.LogFactory;)
private static final Log LOG = LogFactory.getLog(PDCIDFontType0.class);
LOG.warn("Found PFB but expected embedded CFF font " + fd.getFontName());
我花了很长时间尝试了很多事情,并浏览了 SO 中类似问题的答案,但一无所获。
有只小跳蛙
largeQ
相关分类