2

I receive the following message when I deploy my maven/spring application on jboss as7 and attempt to upload a docx file. The message is displayed within the body of the uploaded file when I view it in the app's WYSIWIG editor. The message does not display when I run the app locally on jetty. I included the log4j and docx4j property files. I'm not sure what property would allow me to toggle the debug logging for the docx4j class mentioned in the error and so far I've come up empty on web searches. BTW, my app is not using a log4j/docx4j xml file and from what I've read it's an either or setup. If I should switch to xml, then please let me know and please inform me of which property needs to be adjusted so I can clear this message.

TY

TO HIDE THESE MESSAGES, TURN OFF log4j debug level logging for org.docx4j.convert.out.html.HtmlExporterNG2

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
2
  • Are you sure these properties files are on your class path? Apr 11, 2012 at 22:39
  • @Jason I'm fairly certain that they are. Honestly I'm not 100% sure how to verify that the files are on the class path. I have the files in my src/main/resources folder. From what I read online, the files in the src folder are automatically included on the classpath.
    – mblPrgr
    Apr 12, 2012 at 14:35

6 Answers 6

5

We had a similar issue while using docx4j with Spring Boot.

Since spring-boot-starter-logging auto-configures logback-classic which is used as implementation for loggers, it comes to just setting correct level for package. In our case we didn't need any logging from docx4j therefore adding below line to application.properties disabled whole output from 'docx4j':

logging.level.org.docx4j=OFF

If you specifically need to disable console print of document, then you need to set turn off log level on this particular file:

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

EDIT: I know this topic is old but there are very limited sources targeting this topic while using spring boot. I hope this helps someone in future.

2

I'm not sure how docx4j configures log4j, but you could try changing the docx4j.Log4j.Configurator.disabled=true to false instead.

If that doesn't work you might want to try excluding the servers log4j implementation. You can add a jboss-deployment-structure.xml that excludes log4j.

3
  • I attempted to implement the solution you suggested, but it did not resolve the issue. The link you included also mentions that JBoss 7 requires that the log4j file is manually invoked using the PropertyConfigurator.configure() method. I overlooked that component of the solution, so I will let you know whether or not it helps.
    – mblPrgr
    Apr 12, 2012 at 14:43
  • Maybe try adding log4j.logger.org.docx4j.convert.out.html.HtmlExporterNG2=INFO to your log4j.properties. That syntax might be right, but I think it is. In the end it's probably not a huge deal unless it's clogging up your log file. It looks like a silly informational message. Apr 12, 2012 at 16:05
  • I tried adding the line log4j.logger.org.docx4j.convert.out.html.HtmlExporterNG2=INFO to the prop file, but it didn't make a difference. However excluding log4j from the jboss-d-s.xml file and then manually invoking PropertyConfigurator.configure() cleared the message! Much thanks to you! BTW, the message in question was visible to the user, so I couldn't deploy the app without removing the message.
    – mblPrgr
    Apr 12, 2012 at 17:30
2

change the rootCategory Level from DEBUG to OFF in your log4j.properties or log4j.xml file log4j.rootCategory=OFF, SymbolicNameForAppender

1

I was able to disable the logging output with the following (using docx4j 2.8.1):

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

Note that without the second statement, the logging was not suppressed.

1
  • 2
    Log4jConfigurator is not part of the docx4j or log4j library Mar 16, 2014 at 2:02
1

Use following code:

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

Use this:

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

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.