Bug 9435 - Chainsaw incorrectly loads priority (level) from XML log file
Chainsaw incorrectly loads priority (level) from XML log file
Product: Log4j
Classification: Unclassified
Component: Other
Other other
: P3 normal
: ---
Assigned To: log4j-dev
Depends on:
  Show dependency tree
Reported: 2002-05-27 09:16 UTC by Holger Brands
Modified: 2004-11-16 19:05 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Holger Brands 2002-05-27 09:16:07 UTC
example log entry looks like:
<log4j:event category="de.eurodata.Protokoll" timestamp="1022489698611" 
priority="INFO" thread="AWT-EventQueue-0">
Chainsaw (from log4j 1.2.1) displays it as priority DEBUG.

I think the error is in method XMLFileHandler.startElement(...):

The line
   Priority = Priority.toPriority(aAtts.getValue("level"));
is incorrect in my opinion, because the attribute name in the log4j.dtd
is "priority". As a consequence, Chainsaw is using the default log level 
Comment 1 Holger Brands 2002-05-28 07:27:17 UTC
Note, that this error only occurs, when the XML log file was created with
an "old" Log4J version 1.1.x.
Log4J 1.2.x creates the event attribute "level" as expected by Chainsaw.

(But the distributed log4j.dtd in src/java/org/apache/log4j/xml still lists
"priority" as attribute name, so I was a little confused.)

Comment 2 oliver 2002-05-28 12:59:10 UTC
The problem is that the XMLLayout class is generating XML that does not
conform to the DTD. It uses "level" instead of "priority" as the DTD would
suggest. I was faced with the problem of chosing between making Chainsaw

- the DTD, but not work with 1.1 code
- what the XMLLayout class generates, but not work with 1.2 code
- some kludge that would support both. A kludge is required as there is no
  log4j version information in the output generated by XMLLayout

Not liking kludges I went for the second option. The question is, should we:

- fix XMLLayout to support the DTD;
- put a kludge in Chainsaw to support "level" and "priority"
- do both of the above.

I will do whatever Ceki recommends.
Comment 3 Ceki Gulcu 2002-05-28 14:02:04 UTC
The DTD should be updated to something like:

<!-- The timestamp format is application dependent. -->
<!ATTLIST log4j:event
    logger     CDATA #REQUIRED
    level      CDATA #REQUIRED
    thread     CDATA #REQUIRED
    timestamp  CDATA #REQUIRED

Notice the two changes category -> logger and priority -> level.
I'll also update XMLLayout to conform to the dtd. 
When chainsaw follows suite, we'll release log4j 1.2.4.

There is no point in mulling over this for ages. Reading XMLLayouts is 
relatively new feature such that the number of upset users by the backward 
compatibility problem is likely to be low.
Comment 4 oliver 2002-05-29 11:56:06 UTC
put in the fix as requested by Ceki.