I'm using docx4j to create some docx files from a template. But it keeps generating some annoying loggings when generating it.
This is my log4j.properties file
log4j.rootLogger=ERROR, consoleAppender, fileAppender
log4j.appender.consoleAppender=org.apache.log4j.ConsoleAppender
log4j.appender.consoleAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.consoleAppender.layout.ConversionPattern=%-5p %c %x - %m%n
log4j.appender.fileAppender=org.apache.log4j.RollingFileAppender
log4j.appender.fileAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.fileAppender.layout.ConversionPattern=[%t] %-5p %c %x - %m%n
log4j.appender.fileAppender.File=${catalina.base}/logs/imob86.log
And my docx4j.properties file
docx4j.PageSize=LETTER
docx4j.PageMargins=NORMAL
docx4j.PageOrientationLandscape=false
docx4j.App.write=true
docx4j.Application=docx4j
docx4j.AppVersion=2.7
docx4j.dc.write=true
docx4j.dc.creator.value=docx4j
docx4j.dc.lastModifiedBy.value=docx4j
docx4j.Log4j.Configurator.disabled=true
And this is the code that is generating the logging
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new java.io.File(pathTemplate));
VariablePrepare.prepare(wordMLPackage);
MainDocumentPart documentPart = wordMLPackage.getMainDocumentPart();
documentPart.variableReplace(mappings);
I've searched and found some people suggesting this solution, but it didn't work for me, since I haven't found the Log4jConfigurator
Docx4jProperties.getProperties().setProperty(
"docx4j.Log4j.Configurator.disabled", "true");
Log4jConfigurator.configure();
Does anyone have another solution? Thanks in advance.
As JasonPlutext said above the problem was that docx4j uses slf4j not log4j. Added the slf4j-log4j12-1.7.12.jar
and solved the problem.