logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 43141] New: - LogFilePatternReceiver fails with "%-5p" etc
Date Thu, 16 Aug 2007 08:38:10 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=43141>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=43141

           Summary: LogFilePatternReceiver fails with "%-5p" etc
           Product: Log4j
           Version: unspecified
          Platform: Other
        OS/Version: other
            Status: NEW
          Severity: normal
          Priority: P2
         Component: chainsaw
        AssignedTo: log4j-dev@logging.apache.org
        ReportedBy: lilianne_blaze@tlen.pl


Log file generated with:

  <appender name="xxx"
            class="org.apache.log4j.RollingFileAppender">
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%d %p [%t] %c (%F:%L) - %m%n"/>
    </layout>    

Looks like this:

2007-08-16 10:07:16,453 DEBUG [httpWorkerThread-4848-0] xxx (xxx.java:34) -
debug ***
2007-08-16 10:07:16,453 INFO [httpWorkerThread-4848-0] xxx (xxx.java:35) - info ***
2007-08-16 10:07:16,453 WARN [httpWorkerThread-4848-0] xxx (xxx.java:36) - warn ***
2007-08-16 10:07:16,453 ERROR [httpWorkerThread-4848-0] xxx (xxx.java:37) -
error ***

Chainsaw sees it correctly. It is configured with:

  <plugin name="LogFileReceiver"
class="org.apache.log4j.varia.LogFilePatternReceiver">
    <param name="fileURL" value="xxx"/>
    <param name="timestampFormat" value="yyyy-MM-dd HH:mm:ss,SSS"/> 
    <param name="logFormat"
           value="TIMESTAMP LEVEL [THREAD] LOGGER (FILE:LINE) - MESSAGE"/> 


When log4j is configured with:

<param name="ConversionPattern" value="%d %-5p [%t] %c (%F:%L) - %m%n"/>

Note "%-5p" instead of "%p", which is taken from:
http://logging.apache.org/log4j/docs/api/org/apache/log4j/PatternLayout.html

It outputs:

2007-08-16 10:10:19,875 DEBUG [pool-1-thread-7] xxx (xxx.java:34) - debug ***
2007-08-16 10:10:19,875 INFO  [pool-1-thread-7] xxx (xxx.java:35) - info ***
2007-08-16 10:10:19,875 WARN  [pool-1-thread-7] xxx (xxx.java:36) - warn ***
2007-08-16 10:10:19,875 ERROR [pool-1-thread-7] xxx (xxx.java:37) - error ***

Note "INFO space space [".

Chainsaw sees it as DEBUG "debug ***", DEBUG "info ***", DEBUG "warn ***", ERROR
"error ***"

Apparently double space " " messes up Level parsing, which defaults to DEBUG.

The easiest solution would be to add a String.trim() in private LoggingEvent
convertToEvent(Map fieldMap, String exception[] near "level =
(String)fieldMap.remove("LEVEL"); Level levelImpl = Level.toLevel(level);",
though I don't have the time to test it at this moment.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message