iText7 - 如何设置LoggerFactory? [英] iText7 - How to set up LoggerFactory?

查看:170
本文介绍了iText7 - 如何设置LoggerFactory?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我今天刚刚开始使用iText,所以我开始运行教程#1中的示例。不幸的是我收到这些错误消息:

I just started using iText today so I started by running the example in Tutorial #1. Unfortunately I get these error messages:

Exception thrown: 'System.NullReferenceException' in itext.io.dll
iText.IO.Log.LoggerFactory: No logger factory was bound. Defaulting to no-operation logger implementation.
iText.IO.Log.LoggerFactory: In order to bind a logger factory use     iText.IO.Log.LoggerFactory.BindFactory().

显然我还没有设置一个名为LoggerFactory的东西。我该怎么做?

Obviously I haven't set up something called LoggerFactory. How do I do that?

推荐答案

我们遇到了与C#iText7项目类似的情况,其中

We ran into a similar situation with a C# iText7 project, where

iText.IO.Log.LoggerFactory: No logger factory was bound. Defaulting to no-operation logger implementation.
iText.IO.Log.LoggerFactory: In order to bind a logger factory use     iText.IO.Log.LoggerFactory.BindFactory().

...每次我们尝试运行流程时都会记录,只要我们尝试访问任何iText类。

...would be logged every time we tried to run the process, as soon as we tried to access any iText classes.

我们通过在程序开头添加以下代码来解决这个问题:

We got around this by adding the following code to the beginning of our program:

iText.IO.Log.NoOpLoggerFactory iTextLoggerFactory = new iText.IO.Log.NoOpLoggerFactory();
iText.IO.Log.LoggerFactory.BindFactory(iTextLoggerFactory);

希望这有帮助!

这篇关于iText7 - 如何设置LoggerFactory?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆