plutext / docx4j-ImportXHTML

Converts XHTML to OpenXML WordML (docx) using docx4j
135 stars 124 forks source link

How do you disable logging? #84

Closed helgardwagener closed 2 years ago

helgardwagener commented 2 years ago

Hi, I have been searching for the last 2 days on how to disable logging for this functionality and I have not been able to find any answers. The debug output is insanely large. Please tell me how to disable logging.

plutext commented 2 years ago

If you are using logback, find (or create) logback.xml and check for/add the following line https://github.com/plutext/docx4j/blob/master/docx4j-samples-resources/src/main/resources/logback.xml#L32

That is WARN level, but you could change it to ERROR level if you wanted.

helgardwagener commented 2 years ago

Which would be the best logging framework, I currently have it configured with Log4J which is what the docx4j defaults to. Thank you very much for the feedback, its really appreciated.

plutext commented 2 years ago

What version of docx4j are you using? Logback is what the sample project is configured to use: https://github.com/plutext/docx4j/blob/master/docx4j-samples-docx4j/pom.xml#L71

You'll need to use the correct version for your slf4j-api level (the latest versions are for Java 11+).

helgardwagener commented 2 years ago

I am using docx4j version 8.3.4 with import XHTML version 8.3.2, the consuming application is restricted to Java version 1.8, so I am not sure I can push this to Java version 11+. I will try and use the log back configuration and see what the outcome is. Thanks again.

helgardwagener commented 2 years ago

I have setup logback as the default logging backend with slf4j-api, using the logback XML you provided under resources I am not able to successfully configure the logging. Thank you very much for docx4j and the assistance. New to all of this. I am happy to write it up if you would like for the README?

plutext commented 2 years ago

For Java 8, per https://github.com/plutext/docx4j/blob/VERSION_8_3_4/pom.xml#L317 use

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.26</version>
    </dependency>

with per https://github.com/plutext/docx4j/blob/VERSION_8_3_4/docx4j-samples-docx4j/pom.xml#L72

    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>1.2.10</version>
    </dependency>