wiki:LogFacility
Last modified 10 years ago Last modified on 01/28/08 11:38:47

for now following log categories defined:

logger.org.dcache.authorization
logger.org.dcache.poolselection
logger.org.dcache.poolmonitor
logger.org.dcache.repository
logger.org.dcache.namespace
logger.org.dcache.spacemanagent
logger.org.dcache.io.socket
logger.org.dcache.io.<protocol>
logger.org.dcache.io.disk
logger.org.dcache.io.queue
logger.org.dcache.hsm
logger.org.dcache.cells.messages
logger.org.dcache.db.sql

one class may use more than one category. The categories shared across many classes.

Example:

class SomeClass {

 import org.apache.log4j.Logger;
....

 private static Logger _logSocketIO = Logger.getLogger("logger.dev.org.dcache.io.socket."+SomeClass.class.getName());
 private static Logger _logDiskIO = Logger.getLogger("logger.dev.org.dcache.io.disk."+SomeClass.class.getName()); 

....
  void someMethod () {

       _dataSocket = new Socket(_client_data_host, _client_data_port);
       if( _logSocketIO.isDebugEnabled() ) {
                _logSocketIO.debug("Socket OPEN remote = " + _client_data_host + ":" + _client_data_port +
                                " local = " +_dataSocket.getLocalAddress() + ":" + _dataSocket.getLocalPort() );
       }

   }
....
}

To make life easy following technic can be used ( for Eclipse ):

  1. select line with debug statement
  2. select 'Surround With' from mouse-pulldown menu
  3. select 'Configure Templates'
  4. create new template 'log4j'
  if ( ${var}.isDebugEnabled() ) {
        ${line_selection}
  }

Enabling log4j in dCache

There is already a central log4j property-file to map the suggested log categories to certain output methods (called appenders). It is located at /opt/d-cache/config/log4j.properties. To load that configuration, we need an additional java option in the dCacheSetup:

-Dlog4j.configuration=file:///opt/d-cache/config/log4j.properties

Another useful option is enable the debugging output of the log4j library. Errors in the configuration are then much easier to spot. Just add another java option to dCacheSetup:

-Dlog4j.debug=true

out line formatter

Conversion characters are:

  • %m: Outputs your message.
  • %p: Outputs the priority of the logging event.
  • %r: Outputs the number of milliseconds elapsed since the start of the application until the creation of the logging event.
  • %c: Outputs the category of the logging event. Example: For the category name "a.b.c", the pattern %c{2} will output "b.c". {2} means "output last two components of the dot-separated category name". If no {n} is there, full Category name is output by default.
  • %t: Outputs the name of the thread that generated the logging event.
  • %x: Outputs the nested diagnostic context (NDC) associated with the thread that generated the logging event. Useful when multiple clients are handled by separate threads such as in Java servlets.
  • %n: Outputs the platform-dependent newline character(s). Preferable to specifying "

" or " " etc.

  • %%: Outputs a single percent sign.
  • WARNING: The patterns below will slow down the execution of your program somewhat. Avoid unless execution speed is not an issue.
  • %d: Outputs the date of the logging event. The date conversion specifier may be followed by a date format specifier enclosed between braces. Example: %d{HH:mm:ss,SSS} or %d{dd MMM yyyy HH:mm:ss,SSS}. If no date format specifier is given then ISO8601 format is assumed. The date format specifier admits the same syntax as the time pattern string of Java's SimpleDateFormat which is slow. For faster performance, use %d{ISO8601}, %d{ABSOLUTE}, %d{RELATIVE} (millisecs since program start, fastest) or %d{DATE} which use log4j's ISO8601 DateFormat, AbsoluteTimeDateFormat, RelativeTimeDateFormat and DateTimeDateFormat date formatters respectively.
  • %l: Outputs source code location information. Shortcut for %C.%M(%F:%L).
  • %C: Outputs the fully-qualified class name of the caller issuing the logging request. Example: For the class name "org.apache.xyz.SomeClass", the pattern %C{1} will output "SomeClass". {1} means "output last one component of the fully-qualified class name". If no {n} is there, full class name is output by default.
  • %M: Outputs the method name where the logging request was issued.
  • %F: Outputs the file name where the logging request was issued.
  • %L: Outputs the line number from where the logging request was issued.

SRM logging configuration

located at /opt/d-cache/srm-webapp/WEB-INF/logConfig.xml

AXIS time tracing

  <appender name="axis-trace" class="org.apache.log4j.FileAppender">
    <param name="File" value="/tmp/axis-trace.log"/>
    <param name="Append" value="true"/>
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %m%n"/>
    </layout>
  </appender>



  <category name="org.apache.axis.TIME">
    <appender-ref ref="axis-trace"/>
    <priority value="DEBUG"/>
  </category>

SRM/cell communication tracing

  <appender name="cellmessage" class="org.apache.log4j.FileAppender">
    <param name="File" value="/tmp/cellmessage-trace.log"/>
    <param name="Append" value="true"/>
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %m%n"/>
    </layout>
  </appender>

  <category name="logger.org.dcache.cells.messages">
    <appender-ref ref="cellmessage"/>
    <priority value="DEBUG"/>
  </category>