如何在log4j中为docx4j关闭调试日志记录

时间:2012-04-11 18:47:13

标签: spring maven log4j jboss7.x docx4j

当我在jboss as7上部署我的maven / spring应用程序并尝试上传docx文件时,我收到以下消息。当我在应用程序的WYSIWIG编辑器中查看时,该消息显示在上载文件的正文中。当我在jetty上本地运行应用程序时,不会显示该消息。我包含了log4j和docx4j属性文件。我不确定哪个属性允许我切换错误中提到的docx4j类的调试日志记录,到目前为止我在网上搜索时都是空的。顺便说一句,我的应用程序没有使用log4j / docx4j xml文件,而且从我读过的它是一个或者设置。如果我应该切换到xml,请告诉我,请告知我哪些属性需要调整,以便我可以清除此消息。

TY

要隐藏这些消息,请关闭org.docx4j.convert.out.html.HtmlExporterNG2

的log4j调试级别日志记录

log4j.properties

log4j.rootLogger=ERROR,stdout
#Console Appender 
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%5p] [%t %d{hh:mm:ss}] (%F:%M:%L) %m%n
#Custom assignments
log4j.logger.Controllers=DEBUG,stdout
log4j.logger.Entities=DEBUG,stdout
log4j.logger.Models=DEBUG,stdout
#Disable additivity
log4j.additivity.Controllers=false
log4j.additivity.Entities=false
log4j.additivity.Models=false

docx4j.properties

# Page size: use a value from org.docx4j.model.structure.PageSizePaper enum
# eg A4, LETTER
docx4j.PageSize=LETTER
# Page size: use a value from org.docx4j.model.structure.MarginsWellKnown enum
docx4j.PageMargins=NORMAL
docx4j.PageOrientationLandscape=false
# Page size: use a value from org.pptx4j.model.SlideSizesWellKnown enum
# eg A4, LETTER
pptx4j.PageSize=LETTER
pptx4j.PageOrientationLandscape=false
# These will be injected into docProps/app.xml
# if App.Write=true
docx4j.App.write=true
docx4j.Application=docx4j
docx4j.AppVersion=2.7
# of the form XX.YYYY where X and Y represent numerical values
# These will be injected into docProps/core.xml
docx4j.dc.write=true
docx4j.dc.creator.value=docx4j
docx4j.dc.lastModifiedBy.value=docx4j
#
#docx4j.McPreprocessor=true
# If you haven't configured log4j yourself
# docx4j will autoconfigure it. Set this to true to disable that
docx4j.Log4j.Configurator.disabled=true

6 个答案:

答案 0 :(得分:2)

我不确定docx4j如何配置log4j,但您可以尝试将docx4j.Log4j.Configurator.disabled=true更改为false

如果这不起作用,您可能想尝试排除服务器log4j实现。您可以添加excludes log4j。{/ p> jboss-deployment-structure.xml

答案 1 :(得分:2)

在log4j.properties或log4j.xml文件中将rootCategory级别从DEBUG更改为OFF log4j.rootCategory = OFF,SymbolicNameForAppender

答案 2 :(得分:1)

我能够使用以下内容禁用日志输出(使用docx4j 2.8.1):

Docx4jProperties.getProperties().setProperty(
    "docx4j.Log4j.Configurator.disabled", "true");
Log4jConfigurator.configure();

请注意,如果没有第二个语句,则不会抑制日志记录。

答案 3 :(得分:1)

使用以下代码:

Docx4jProperties.getProperties().setProperty("docx4j.Log4j.Configurator.disabled", "true");
Log4jConfigurator.configure();            
org.docx4j.convert.out.pdf.viaXSLFO.Conversion.log.setLevel(Level.OFF);

答案 4 :(得分:1)

使用这个:

LogManager.getLogger("org.docx4j").setLevel(Level.OFF);

答案 5 :(得分:0)

在Spring Boot中使用docx4j时出现类似问题。 由于spring-boot-starter-logging自动配置了logback-classic(用作记录程序的实现),因此只需要为软件包设置正确的级别即可。在我们的情况下,我们不需要来自docx4j的任何日志记录,因此将以下行添加到application.properties会禁用'docx4j'的整个输出:

logging.level.org.docx4j=OFF

如果您具体需要禁用文档的控制台打印,则需要为此特定文件设置关闭日志级别:

logging.level.org.docx4j.model.datastorage.migration.VariablePrepare=OFF

编辑: 我知道这个主题很旧,但是使用Spring Boot时针对这个主题的资源非常有限。我希望这对以后的人有所帮助。