What is the mechanism for logging error/warning information?

I would like to know where to find Nuxeo log files ? How are those files managed?

  • how does one specify the logging level ?
  • what is the cleanup policy for old log files ?
  • how can I send error messages to a separate file ?
1 votes

2 answers

5403 views

ANSWER



First to know where are the logging file, you have to look 2 things:

  • you can look that you have at the beginning of the console Nuxeo configuration: /the/location/of/the/nuxeo.conf. Into this file, look the value of nuxeo.log.dir. If there is a “#” before the value is the default one: “$NUXEO_HOME/log”
  • look into “$NUXEO_HOME/lib/log4j.xml for tomcat
  • look into “$NUXEO_HOME/sever/default/conf/jboss-log4j.xml for jboss

this xml file contains all information of how log4j will produce logs.

You have to understand 2 notions:

  • appender items define a container where log4j will create logs and with the information of the format
  • category items define a level of logs that log4j will expose and on which appender for each java package

Configuration specified into a category on a package will be inherited for all children packages. So if you specify that category:

  <category name="org.nuxeo.ecm">
    <priority value="INFO" />
    <appender-ref ref="CONSOLE" />
    <appender-ref ref="FILE" />
  </category>

all sub-packages (org.nuxeo.ecm.platform, org.nuxeo.ecm.runtime, …) will produce INFO logs and higher logs (WARN, ERROR and FATAL) into the FILE appender and the CONSOLE appender

There is a special category specified by the root item. His configuration will transmit this configuration to “org”, “fr”, … packages.

About the appender configuration, you can look into the log4j documentation, but I can give you some example here:

  <appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
    <errorHandler class="org.apache.log4j.helpers.OnlyOnceErrorHandler" />
    <param name="File" value="${nuxeo.log.dir}/server.log" />
    <param name="Append" value="true" />
    <!-- Rollover at midnight every day -->
    <param name="DatePattern" value="'.'yyyy-MM-dd" />
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%d{ISO8601} %-5p [%c] %m%n" />
    </layout>
  </appender>

is an appender that write logs into a file daily rolling (a new file will be regenerated each day). The file is create into the “nuxeo.log.dir” directory (value given by the nuxeo.conf) into the server.log file. The layout item specify how log4j will expose each line of logs. %d represent the date, %c the class responsible of the log.

  <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
    <errorHandler class="org.apache.log4j.helpers.OnlyOnceErrorHandler" />
    <param name="Target" value="System.out" />
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n" />
    </layout>
    <filter class="org.apache.log4j.varia.LevelRangeFilter">
      <param name="levelMin" value="INFO" />
    </filter>
  </appender>

is an appender that writes logs into the console of the server. The levelMin value INFO ask to not display logs lower than INFO (DEBUG and TRACE). We do that a part because on some system console logging are written synchronously. So if you log too much thing, this will slow down the server.

There is many many possibilities of appender (SMTP, SNMTP, SMS …) and configuration possibilities. I let you discover that…

2 votes



Approving this answer, just leaving this note in this comment, so that the root logger is not forgotten, as it manages how all appenders receive their logging information.

If you want to see the debug output, you need to modify the log4j.xml root entry to say the following (in this case FILE refers to server.log attached appender.

<pre> <root>

&lt;level value=&quot;DEBUG&quot;/&gt;
&lt;appender-ref ref=&quot;FILE&quot;/&gt;

</root> </pre>

12/07/2011

I don't want to modify the files in lib/ (why would anyone put a configuration file in a "lib" directory??). Can the file location be changed via an environment variable, configuration directive or command line?
11/09/2016

This is Tomcat-specific, we didn't invent this location. I'll refer you to the Tomcat documentation for that.
11/09/2016


The error information will go to the server.log, which is a global catch-it-all log in default configutration, as well as nuxeo-error.log, used just for error output. This behavior can be modified in your log4j.xml file in the lib directory of the server.

<$NUXEO_HOME>/lib/log4j.xml

The output that you see depends on the logging level in the appender. If you want to see the debug output, you need to modify the log4j.xml root entry to say the following (in this case FILE refers to server.log.

 
0 votes