我有一个小型Java程序,可以分割pdf文件,分隔符是每个文件页面底部的PDF417条形码。程序中使用了PDFbox。而我的工作环境中java版本是java 8。
当我在 IntelliJ 中运行程序时,控制台中显示太多警告消息(当程序在 CMD 中运行时也会发生同样的情况),
我想知道如何停止这些警告消息,因为字体和任何其他信息对我来说都是不必要的。 PDF417的值是程序只关心的值。
而且,放映会影响性能吗?
控制台上的消息如下所示:
Jan 21, 2025 11:09:55 AM org.apache.pdfbox.pdmodel.font.PDType0Font toUnicode
WARNING: No Unicode mapping for CID+121 (121) in font AllAndNone
Jan 21, 2025 11:09:55 AM org.apache.pdfbox.pdmodel.font.PDType0Font toUnicode
WARNING: No Unicode mapping for CID+89 (89) in font AllAndNone
Jan 21, 2025 11:09:55 AM org.apache.pdfbox.pdmodel.font.PDType0Font toUnicode
WARNING: No Unicode mapping for CID+41 (41) in font AllAndNone
log4j2.xml如下:
<Configuration status="INFO">
<Appenders>
<Console name="ConsoleAppender" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%thread] %-5level %c{1}\(%line\) - %msg%n" />
</Console>
<File name="Main" fileName="logs/${sys:curUsr}-${date:yyyyMMdd-HHmm}.log" immediateFlush="true" append="true">
<PatternLayout pattern="%d{MM/dd/yyyy-HH:mm:ss} %-5level %c{1}\(%line\) - %msg%n"/>
</File>
<File name="Other" fileName="logs/other.log" immediateFlush="false" append="false">
<PatternLayout pattern="%d{MM/dd/yyyy-HH:mm:ss} %-5level %c{1}\(%line\) - %msg%throwable%n"/>
</File>
<File name="ErrorFile" fileName="logs/error.log" immediateFlush="false" append="false">
<PatternLayout pattern="%d{MM/dd/yyyy-HH:mm:ss} %-5level %c{1}\(%line\) - %msg%throwable%n"/>
</File>
</Appenders>
<Loggers>
<Root level="ERROR">
<AppenderRef ref="ConsoleAppender" />
<AppenderRef ref="Main"/>
</Root>
<Logger name="org.apache.fontbox" level="ERROR">
<AppenderRef ref="ErrorFile"/>
<AppenderRef ref="ConsoleAppender" />
</Logger>
<Logger name="org.apache.pdfbox" level="ERROR">
<AppenderRef ref="ErrorFile"/>
<AppenderRef ref="ConsoleAppender" />
</Logger>
<Logger name="org.apache.pdfbox.pdmodel" level="ERROR">
<AppenderRef ref="ErrorFile"/>
<AppenderRef ref="ConsoleAppender" />
</Logger>
<Logger name="org.apache.pdfbox.pdmodel.font" level="ERROR">
<AppenderRef ref="ErrorFile"/>
<AppenderRef ref="ConsoleAppender" />
</Logger>
</Loggers>
</Configuration>
pom.xml 中的依赖项是:
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.17.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.17.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>3.4.1</version>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>2.0.24</version>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox-tools</artifactId>
<version>2.0.0-RC1</version>
</dependency>
</dependencies>