Page 1 of 1

turning off logging in pdf output

PostPosted: Thu Jun 23, 2011 9:41 pm
by qhfcrystal
Hi jason:
After I convert my docx to pdf. i got a message in my pdf saying: to hide these messages, turn off log4j debug level logging for org.docx4j.convert.out.pdf.viaXSLFO.
I don't know way will this message comes up and I have no idea how could i turn off the debug level for viaXSLFO. I have tried to turn root value to be off. However, i still got the message in my pdf. Do you know a way to erase this message?

Re: turning off logging in pdf output

PostPosted: Thu Jun 23, 2011 11:13 pm
by jason
Have you followed the instructions in the Getting Started guide?

If you have, feel free to post your log4j properties file, and someone may be able to point out what's wrong.

Re: turning off logging in pdf output

PostPosted: Fri Jun 24, 2011 2:13 pm
by qhfcrystal
Here's my xml config file

Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
   <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
          
   <!-- To see log output when running samples from within Eclipse,
            in the Eclipse run dialog, arguments tab, enter the following
            as a program argument:
          
             -Dlog4j.configuration=src/main/resources/log4j.xml
          
           -->     
   
       <!-- ====================================================================== -->
       <!-- A P P E N D E R S                                                      -->
       <!-- ====================================================================== -->
   
       <!-- console -->
       <appender name="console" class="org.apache.log4j.ConsoleAppender">
           <layout class="org.apache.log4j.PatternLayout">
               <param name="ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* %c{1}: %m (%F, line %L)%n"/>
           </layout>
       </appender>
   
       <!-- error.log -->
       <appender name="error" class="org.apache.log4j.FileAppender">
           <param name="File" value="logs/docx4j.log"/>
           <layout class="org.apache.log4j.PatternLayout">
               <param name="ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* %c{1}: %m (%F, line %L)%n"/>
           </layout>
       </appender>
   
       <!-- ====================================================================== -->
       <!-- L O G G E R S                                                          -->
       <!-- ====================================================================== -->
   
   
    <logger name="org.apache.commons">
                   <level value="info"/>
           </logger>
   
       <logger name="org.docx4j">
                   <level value="info"/>
           </logger>       
          
           <logger name="org.docx4j.jaxb">
                                   <level value="error"/>
           </logger>       
   
              
       <logger name="org.docx4j.document.wordprocessingml">
                   <level value="info"/>
           </logger>
          
       <logger name="org.docx4j.openpackaging">
                   <level value="info"/>
           </logger>
   
       <logger name="org.docx4j.openpackaging.io">
                   <level value="debug"/>
           </logger>
   
       <logger name="org.docx4j.openpackaging.packages">
                   <level value="info"/>
           </logger>
   
       <logger name="org.docx4j.openpackaging.parts">
                   <level value="debug"/>
           </logger>
   
       <logger name="org.docx4j.fonts">
                   <level value="debug"/>
           </logger>
   
   
       <root>
           <level value="off" />
           <appender-ref ref="console"/>
           <!-- <appender-ref ref="error"/> -->       </root>
   
</log4j:configuration>

Re: turning off logging in pdf output

PostPosted: Sat Jun 25, 2011 12:00 am
by jason
Is your log4j config file being found at all? ie are you seeing any docx4j related logging in the console?

Re: turning off logging in pdf output

PostPosted: Tue Jun 28, 2011 8:58 pm
by tinne
qhfcrystal wrote:
Code: Select all
<logger name="org.docx4j">
    <level value="info"/>
</logger>


This overrides the settings for root and sets the logging level for each category (package below) org.docx4j... to info. Thus the settings for the root category (which corresponds to the default package/no package statement) is overwritten. Please consult the log4j docs for the exact mimics.

Re: turning off logging in pdf output

PostPosted: Tue Jul 05, 2011 11:14 pm
by qhfcrystal
Hi
I've turned all the value for logger to off, however I still get the thing appears with my pdf. could any one help?
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
   <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
          
   <!-- To see log output when running samples from within Eclipse,
            in the Eclipse run dialog, arguments tab, enter the following
            as a program argument:
          
             -Dlog4j.configuration=src/main/resources/log4j.xml
          
           -->     
   
       <!-- ====================================================================== -->
       <!-- A P P E N D E R S                                                      -->
       <!-- ====================================================================== -->
   
       <!-- console -->
       <appender name="console" class="org.apache.log4j.ConsoleAppender">
           <layout class="org.apache.log4j.PatternLayout">
               <param name="ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* %c{1}: %m (%F, line %L)%n"/>
           </layout>
       </appender>
   
       <!-- error.log -->
       <appender name="error" class="org.apache.log4j.FileAppender">
           <param name="File" value="logs/docx4j.log"/>
           <layout class="org.apache.log4j.PatternLayout">
               <param name="ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* %c{1}: %m (%F, line %L)%n"/>
           </layout>
       </appender>
   
       <!-- ====================================================================== -->
       <!-- L O G G E R S                                                          -->
       <!-- ====================================================================== -->
   
   
    <logger name="org.apache.commons">
                   <level value="off"/>
           </logger>
   
       <logger name="org.docx4j">
                   <level value="off"/>
           </logger>       
          
           <logger name="org.docx4j.jaxb">
                                   <level value="off"/>
           </logger>       
   
              
       <logger name="org.docx4j.document.wordprocessingml">
                   <level value="off"/>
           </logger>
          
       <logger name="org.docx4j.openpackaging">
                   <level value="off"/>
           </logger>
   
       <logger name="org.docx4j.openpackaging.io">
                   <level value="off"/>
           </logger>
   
       <logger name="org.docx4j.openpackaging.packages">
                   <level value="off"/>
           </logger>
   
       <logger name="org.docx4j.openpackaging.parts">
                   <level value="off"/>
           </logger>
   
       <logger name="org.docx4j.fonts">
                   <level value="off"/>
           </logger>
   
   
       <root>
           <level value="off" />
           <appender-ref ref="console"/>
           <!-- <appender-ref ref="error"/> -->       </root>
   
</log4j:configuration>

Re: turning off logging in pdf output

PostPosted: Tue Jul 05, 2011 11:52 pm
by jason
If you are sure your config file is being found, check your class path for other log4j config files (including within jars).

If you remove your log4j config file (and assuming you are not using a recent svn build which does auto log4j config), what warnings does log4j print to your console?

Re: turning off logging in pdf output

PostPosted: Wed Jul 06, 2011 8:32 pm
by tinne
1. You can turn on log4j setup debugging by configuring it <log4j:configuration debug="true">...</log4j:configuration>.

2. There are some nasty System.(out|err).printlns left in docx4j. Try searching the source code for some output which looks static or, if that does not help, post what you're doing and your output.

Re: turning off logging in pdf output

PostPosted: Fri Jul 08, 2011 9:27 pm
by qhfcrystal
Hi jason and tinne:

Thx for your reply. Actually now i'm beginning to use the newly developed 2.7.0. I have two questions here.
1. with the automatically configured log4j, I could see so many [info] output in my screen and actually I don't like to see them. How could I turn them off?
2. with the old subversion, i could successfully built a PDF though I get the turn off log 4j header for some reason, however, for this 2.7.0 version, I will get error about the fo.
pls see below:

FOP issues:
Detailed error message: java.xml.transform.TransformerException: org.apache.fop.fo.ValidationException:For "fo:root","fo:layout-master-set" must be declared before "fo:page-sequence!" <See position 1:168>

Re: turning off logging in pdf output

PostPosted: Fri Jul 08, 2011 9:48 pm
by jason
qhfcrystal wrote:1. with the automatically configured log4j, I could see so many [info] output in my screen and actually I don't like to see them. How could I turn them off?


Just add your own log4j configuration file to your classpath - same as previously.

qhfcrystal wrote:2. with the old subversion, i could successfully built a PDF though I get the turn off log 4j header for some reason, however, for this 2.7.0 version, I will get error about the fo.
pls see below:

FOP issues:
Detailed error message: java.xml.transform.TransformerException: org.apache.fop.fo.ValidationException:For "fo:root","fo:layout-master-set" must be declared before "fo:page-sequence!" <See position 1:168>


Please upload a simple docx which exhibits the issue, and I'll take a look. Could you start a new topic for this issue please?

Re: turning off logging in pdf output

PostPosted: Sun Jul 10, 2011 8:56 pm
by qhfcrystal
Hi Jason and tinee:

Thx for your advise and finally i know why i keep get failed in this area. As jason said, all about this is the JAVA path. I build this with a linux system. I place the Jar i use in a dir and the properties is in the classpath. However, when call the jar, it could not find the properties. Finally, i use inputstream and outputstream to readin the properties first and output it in the dir where the jar is called. Then the properties could be find out after all.

Re: turning off logging in pdf output

PostPosted: Tue Jul 12, 2011 9:01 am
by tinne
Did you mean you ran it using "java -jar your-docx-exe.jar"? Then, classpath is restricted to just the jar. Add the log4j.xml to your jar (jar uvf your-docx-exe.jar log4j.xml) and you will be done.

Re: turning off logging in pdf output

PostPosted: Thu Jul 04, 2013 1:27 am
by hardywang
Is there a way to change the configuration programmatically instead of using configuration file?

Re: turning off logging in pdf output

PostPosted: Thu Jul 04, 2013 5:57 am
by tinne
Programmatic configuration can be done. See here:

Ceki Gülcü (2002): Short introduction to log4j. Section Configuration. http://logging.apache.org/log4j/1.2/manual.html