Hi Paul,

You are right. The value returned by LoggingEvent.getLocationInfo()
can be null but it should not be. I think it should be the
responsibility of the receiver/decoder to set location info to a
default non-null value if location info is unavailable at
deserialisation time.

For example, the readObject method in LoggingEvent is coded as
follows.

  private void readObject(ObjectInputStream ois)
         throws java.io.IOException, ClassNotFoundException {
    ois.defaultReadObject();
    readLevel(ois);

    // Make sure that location info instance is set.
    if (locationInfo == null) {
      locationInfo = LocationInfo.NA_LOCATION_INFO;   <--- this is noteworthy
    }
  }

As you can see, if there is no location information in the serialized
event, readObject method sets it to NA_LOCATION_INFO, which is a
default value having all fields set to the string "?".

Although it is perfectly legitimate for the Chainsaw Generator to
generate evens with null location information, the receiver of such
information should set location info to a default value.

Would you agree with this assessment?

At 12:24 AM 5/11/2004, [EMAIL PROTECTED] wrote:
psmith 2004/05/10 15:24:22

  Modified:    src/java/org/apache/log4j/pattern
                        ClassNamePatternConverter.java
                        LineLocationPatternConverter.java
                        FullLocationPatternConverter.java
                        FileLocationPatternConverter.java
                        MethodLocationPatternConverter.java
  Log:
  ocationInfo not always non-null... At least not when the Chainsaw Generator
  creates it.

Just adds a simple if.

Revision Changes Path
1.4 +1 -1 logging-log4j/src/java/org/apache/log4j/pattern/ClassNamePatternConverter.java


Index: ClassNamePatternConverter.java
===================================================================
RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/pattern/ClassNamePatternConverter.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ClassNamePatternConverter.java 27 Feb 2004 16:47:32 -0000 1.3
+++ ClassNamePatternConverter.java 10 May 2004 22:24:22 -0000 1.4
@@ -35,7 +35,7 @@
}


String getFullyQualifiedName(LoggingEvent event) {
- return event.getLocationInformation().getClassName();
+ return event.getLocationInformation()!=null?event.getLocationInformation().getClassName():"";
}


}




-- Ceki G�lc�

For log4j documentation consider "The complete log4j manual"
ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to