Dashboard > Documentation > ... > 2. Developer Guide > 2.12. Logging

View Info

2.12. Logging

 Documentation Summary
 Page Summary

Installation

Granite Data Services uses Log4j to display debugging informations. While log4j.jar is already bundled with JBoss and available automatically in the classpath, it is not packaged by default in Tomcat (and some other servlet containers as well). If you are deploying your GDS applications to Tomcat, you must add a log4j.jar to your <MY_WAR>/WEB-INF/lib directory.

If you don't deploy log4j.jar in Tomcat, your application won't be able to start!

Configuration

JBoss

Edit <JBOSS_HOME>/server/default/conf/[jboss-]log4j.xml and make the following changes:

log4j.xml (JBoss)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
   ...
   <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
      ...
      <!-- change console threshold to "DEBUG" --> 
      <param name="Threshold" value="DEBUG"/>
      ...
   </appender>
   ...
   <!-- insert those 3 categories before the "root" node -->
   <category name="org">
      <priority value="INFO" />
   </category>
   <category name="com">
      <priority value="INFO" />
   </category>
   <category name="org.granite.messaging.webapp.AMFMessageServlet">
      <priority value="DEBUG" />
   </category>

   <root>
      <appender-ref ref="CONSOLE"/>
      ...
   </root>
   ...
</log4j:configuration>
Tomcat

Put a new log4j.xml in the <MY_WAR>/WEB-INF/classes directory (create this directory if it does not exist). Your log4j.xml file could look like that (taken from graniteds-pojo-1.0.0.zip):

log4j.xml (Tomcat)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">

    <appender name="FILE" class="org.apache.log4j.RollingFileAppender">
        <param name="File" value="${catalina.home}/logs/graniteds-pojo.log"/>
        <param name="Threshold" value="INFO"/>
        <param name="Append" value="false"/>
        <param name="MaxFileSize" value="1MB"/>
        <param name="MaxBackupIndex" value="1"/>
                
        <layout class="org.apache.log4j.PatternLayout">
            <param
                name="ConversionPattern"
                value="%d %-5p %X{service} %X{user} [%c] %m%n"/>
        </layout>             
    </appender>

    <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
        <param name="Target" value="System.out"/>
        <param name="Threshold" value="DEBUG"/>

        <layout class="org.apache.log4j.PatternLayout">
            <param
                name="ConversionPattern"
                value="%d{ABSOLUTE} %-5p %X{service} %X{user} [%c{1}] %m%n"/>
        </layout>
    </appender>

    <category name="org.granite">
        <priority value="INFO" />
    </category>
    <category name="org.granite.messaging.webapp.AMFMessageServlet">
        <priority value="DEBUG" />
    </category>

    <root>
        <appender-ref ref="CONSOLE"/>
        <appender-ref ref="FILE"/>
    </root>

</log4j:configuration>

Sample output

Here is a sample of what you will see after activating logging:

16:48:43,328 DEBUG [AMFMessageServlet] >> Processing AMF0 request:
org.granite.messaging.amf.AMF0Message {
  version = 3
  headers = []
  bodies = [
    org.granite.messaging.amf.AMF0Body {
      target = null
      serviceName = null
      serviceMethodName = null
      response = /3
      type = ARRAY
      value = [
        flex.messaging.messages.CommandMessage {
          messageRefType: null
          operation: LOGIN
          correlationId = 
          destination = 
          headers = {DSId=7ECE0DE5-3DC6-4067-95AC-1C63CADAB6FF}
          messageId = 5A17A814-37C8-224B-651C-12735A309D61
          timestamp = 0
          clientId = null
          timeToLive = 0
          body = ****** (credentials)
        }
      ]
    },
    org.granite.messaging.amf.AMF0Body {
      target = null
      serviceName = null
      serviceMethodName = null
      response = /4
      type = ARRAY
      value = [
        flex.messaging.messages.RemotingMessage {
          source = null
          operation = findAllPersons
          correlationId = null
          destination = person
          headers = {DSId=7ECE0DE5-3DC6-4067-95AC-1C63CADAB6FF, DSEndpoint=my-graniteamf}
          messageId = 98ADE9D1-2B42-DD9A-1864-12735A407C86
          timestamp = 0
          clientId = 87FD89FF-2FC3-4B43-A4B6-08F0C61AEE2C
          timeToLive = 0
          body = []
        }
      ]
    }
  ]
}
16:48:44,078 DEBUG [AMFMessageServlet] << Returning AMF0 response:
org.granite.messaging.amf.AMF0Message {
  version = 3
  headers = []
  bodies = [
    org.granite.messaging.amf.AMF0Body {
      target = /3/onResult
      serviceName = null
      serviceMethodName = null
      response = 
      type = AMF3_OBJECT
      value = flex.messaging.messages.AcknowledgeMessage {
        correlationId = 5A17A814-37C8-224B-651C-12735A309D61
        destination = null
        headers = {}
        messageId = 3DCC44CE-D163-45FB-904B-4E7EC3AB5E02
        timestamp = 1185720523468
        clientId = B62463FB-C477-4535-864F-E91C63093A16
        timeToLive = 0
        body = success
      }
    },
    org.granite.messaging.amf.AMF0Body {
      target = /4/onResult
      serviceName = null
      serviceMethodName = null
      response = 
      type = AMF3_OBJECT
      value = flex.messaging.messages.AcknowledgeMessage {
        correlationId = 98ADE9D1-2B42-DD9A-1864-12735A407C86
        destination = null
        headers = {}
        messageId = F61FABF6-A71B-493C-A15E-9BC6D289973F
        timestamp = 1185720524078
        clientId = 67EBFD5C-CF20-426D-9F66-2BA14BE9B893
        timeToLive = 0
        body = [test.granite.ejb3.entity.Person@30af1099]
      }
    }
  ]
}

Quick legend

[...] means: array or List and its content.
{...} means: map or typed object (prefixed with its full class name) and its content.


Browse Space
- Pages
- Labels
- Attachments
- Mail
- Bookmarks
- News
- Activity
- Advanced

Explore Confluence
- Popular Labels
- Notation Guide

Your Account
Log In

Other Features

View a printable version of the current page.

Add Content
- Add Comment


Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.6.0 Build:#913 Sep 27, 2007)
Bug/feature request - Contact Administrators

SourceForge.net Logo
Copyright © 2007-2008 Adequate Systems. All Rights Reserved.