Quantcast
Channel: Disable PDFBox logging with Springboot org.apache.commons.logging - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Disable PDFBox logging with Springboot org.apache.commons.logging

$
0
0

I can't find a way to stop warnings from PDFBox I am using in a psring boot application. For example:

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

I have tried: In Application file:

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);
  }

}

As parameter when running jar:

-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.NoOpLog
-Dorg.slf4j.simpleLogger.defaultLogLevel=off

Within the PDFBox code, the log is set up using:

(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());

I've spent a long time trying a lot of things and trolled through the answers for similar questions in SO but not got anywhere.


Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images