logging.dita 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
  3. <!-- This file is part of the DITA Open Toolkit project. See the accompanying LICENSE file for applicable license. -->
  4. <concept id="loghandling">
  5. <title>Logging build information</title>
  6. <titlealts>
  7. <navtitle>Logging</navtitle>
  8. </titlealts>
  9. <shortdesc>When you run DITA-OT, key information is logged on the screen. This information can also be written to a
  10. log file. If you encounter a problem, you can analyze this information to determine the source of the problem and
  11. then take action to resolve it.</shortdesc>
  12. <prolog>
  13. <metadata>
  14. <keywords>
  15. <indexterm>Apache FOP
  16. <indexterm>log files</indexterm></indexterm>
  17. <indexterm><cmdname>dita</cmdname> command
  18. <indexterm>logging</indexterm></indexterm>
  19. <indexterm>logging</indexterm>
  20. <indexterm>verbose logging</indexterm>
  21. <indexterm>Ant
  22. <indexterm>logging</indexterm></indexterm>
  23. <indexterm>debugging
  24. <index-see-also>logging</index-see-also></indexterm>
  25. <indexterm>Java
  26. <indexterm>logging</indexterm></indexterm>
  27. </keywords>
  28. </metadata>
  29. </prolog>
  30. <conbody>
  31. <p>The logging behavior varies depending on whether you use the <cmdname>dita</cmdname> command or Ant to invoke a
  32. toolkit build.</p>
  33. <dl>
  34. <dlentry>
  35. <dt><cmdname>dita</cmdname> command</dt>
  36. <dd>
  37. <p>By default, only warning and error messages are written to the screen.</p>
  38. <ul>
  39. <li>
  40. <p>For more information, enable verbose logging with <cmdname>dita</cmdname>
  41. <parmname>--verbose</parmname>.</p>
  42. <p>Verbose logging prints additional information to the console, including directory settings, effective
  43. values for Ant properties, input/output files, and informational messages to assist in
  44. troubleshooting.</p></li>
  45. <li>
  46. <p>To enable debug logging, use <cmdname>dita</cmdname>
  47. <parmname>--debug</parmname>.</p>
  48. <p>Debug logging prints considerably more additional information. The debug log includes all information
  49. from the verbose log, plus details on Java classes, additional Ant properties and overrides,
  50. preprocessing filters, parameters, and stages, and the complete build sequence.</p>
  51. <note type="attention">Debug logging requires additional resources and can slow down the build process, so
  52. it should only be enabled when further details are required to diagnose problems.</note>
  53. </li>
  54. <li>
  55. <p>To write the log to a file, use <cmdname>dita</cmdname>
  56. <parmname>--logfile</parmname>=<varname>file</varname> and specify the path to the log file.</p>
  57. <p>Unless an absolute path is specified, the value will be interpreted relative to the current
  58. directory.</p></li>
  59. </ul></dd>
  60. </dlentry>
  61. <dlentry>
  62. <dt>Ant</dt>
  63. <dd>By default, status information is written to the screen. If you issue the <parmname>-l</parmname> parameter,
  64. the build runs silently and the information is written to a log file with the name and location that you
  65. specified.</dd>
  66. </dlentry>
  67. </dl>
  68. <section>
  69. <title>Using other Ant loggers</title>
  70. <p>You also can use other Ant loggers; see
  71. <xref href="https://ant.apache.org/manual/listeners.html" format="html" scope="external">Listeners &amp;
  72. Loggers</xref> in the Ant documentation for more information.</p>
  73. <p>For example, you can use the <b>AnsiColorLogger</b> to colorize the messages written on the screen.</p>
  74. <dl>
  75. <dlentry>
  76. <dt><cmdname>dita</cmdname> command</dt>
  77. <dd>
  78. <p>To use a custom Ant logger with the <cmdname>dita</cmdname> command, add the logger to the
  79. <codeph>ANT_ARGS</codeph> environment variable by calling the following command before calling the
  80. <cmdname>dita</cmdname> command:</p>
  81. <codeblock>export ANT_ARGS="-logger org.apache.tools.ant.listener.AnsiColorLogger"</codeblock>
  82. <p>Now you will get colorized messages when the <cmdname>dita</cmdname> command runs.</p>
  83. <note type="tip">Environment variables can also be set permanently. See
  84. <xref href="https://www.java.com/en/download/help/path.xml" format="html" scope="external">How do I set or
  85. change the PATH system variable?</xref> for information on how to set the <codeph>PATH</codeph>
  86. environment variable. You can set the <codeph>ANT_ARGS</codeph> environment variable in the same
  87. way.</note>
  88. </dd>
  89. </dlentry>
  90. <dlentry>
  91. <dt>Ant</dt>
  92. <dd>
  93. <p>If you prefer to launch DITA-OT directly from Ant, you can also add the logger to the
  94. <codeph>ANT_ARGS</codeph> environment variable, as explained above. You can also set the logger with the
  95. <codeph>-logger</codeph> parameter when calling Ant.</p>
  96. <codeblock>ant -logger org.apache.tools.ant.listener.AnsiColorLogger</codeblock>
  97. </dd>
  98. </dlentry>
  99. </dl>
  100. </section>
  101. <section>
  102. <title>FOP debug logging</title>
  103. <indexterm>logback.xml</indexterm>
  104. <indexterm>classpath
  105. <indexterm>logging</indexterm></indexterm>
  106. <p>In PDF processing with <tm trademark="Apache" tmtype="tm">Apache</tm> FOP, DITA-OT uses the Simple Logging
  107. Facade for Java (SLF4J) for better control and formatting of FOP log messages. To reduce noise on the console,
  108. all FOP messages are set to the Info level and hidden by default.</p>
  109. <p>To enable debug logging, modify the <filepath>config/logback.xml</filepath> file or add your own
  110. <filepath>logback.xml</filepath> to the classpath with a higher priority to override the default settings. For
  111. more information, see the
  112. <xref href="https://logback.qos.ch/manual/configuration.html" format="html" scope="external">Logback
  113. configuration documentation</xref>.</p>
  114. <note type="attention">Enabling FOP debug logging will dramatically increase the size of generated log
  115. files.</note>
  116. </section>
  117. <!--<section><title>Analyze messages on the screen</title><p>During the building process, some information or messages
  118. occur on the screen to tell you about the status, warnings, errors, or fatal errors. You need to analyze the
  119. messages to solve the problems. <ul>
  120. <li>If the build succeeded with some warning messages on the screen, it means that there are something
  121. incorrect within the user input parameters or source DITA files; but you can still get the correct
  122. output.</li>
  123. <li>If the build succeeded with some error messages on the screen, it means that there are something incorrect
  124. within the user input parameters or source DITA files; the output maybe not correct.</li>
  125. <li>If the build failed with fatal error message on the screen, it means that there are something illegal or
  126. invalid within the user input parameters or source DITA files; you may get no output, or wrong output.</li>
  127. </ul>
  128. </p></section>-->
  129. <!--<section><title>Analyze messages in the log file</title><p>A log file in plain text format is generated in the log
  130. directory, which has a name combined with both input file name and transformation type. You can open it and find more
  131. detailed information, which are helpful for solving problems. You can use the same way introduced above to
  132. analyze the messages and solve the problems.</p><p>The log directory can be specified by:</p><ul>
  133. <li>using Ant, with argument <codeph>-logfile=<userinput>log-file</userinput></codeph></li>
  134. <li>using command-line tool, the parameter <codeph>/logdir:<userinput>log-dir</userinput></codeph>.</li>
  135. </ul></section>-->
  136. <!--<section><title>Turn on debug mode</title><p>Under debug mode, diagnostic information, such as: environment
  137. variables, stack trace, will be logged into the log file. These information can help the user or developer to go
  138. deep into the problems and find the root cause.</p><p>By default, the debug mode is disabled. To turn on the
  139. debug mode on, you need to follow the usage below: <ul>
  140. <li>Append <codeph>-v</codeph> and <codeph>-Dargs.debug=yes</codeph> in Ant command.</li>
  141. <li>Append <codeph>/d</codeph> or <codeph>/debug</codeph> in command-line tool.</li>
  142. </ul></p></section>-->
  143. </conbody>
  144. </concept>