Log4j Version 1.2.7: Class Logging
|
Log4j 1.2.7 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.log4j.performance.Logging
Measure the performance of logging.
Experimental results are listed below in units of micro-seconds. Measurements were done on a AMD Duron clocked at 800Mhz running Windows 2000 and Sun's 1.3 JDK.
Layout | NullAppender | FileAppender | FileAppender (no flush) | AsyncAppender (no flush) |
---|---|---|---|---|
SimpleLayout | 4 | 21 | 16 | 33 |
PatternLayout "%p - %m%n" | 4 | 21 | 16 | 32 |
PatternLayout "%-5p - %m%n" | 4 | NA | NA | NA |
TTCCLayout/RELATIVE | 10 | 37 | 31 | 45 |
PatternLayout "%r [%t] %-5p %c{2} %x - %m%n" | 11 | NA | NA | NA |
PatternLayout "%r [%t] %-5p %.10c %x - %m%n" | 11 | NA | NA | NA |
PatternLayout "%r [%t] %-5p %.20c %x - %m%n" | 11 | NA | NA | NA |
PatternLayout "%r [%t] %-5p %c - %m%n" | 9 | 36 | 29 | 45 |
TTCCLayout/ISO8601 | 25 | 58 | 51 | 71 |
PatternLayout "%d{ISO8601} [%t] %-5p %c %x - %m%n" | 28 | 62 | 55 | 76 |
PatternLayout "%d{yyyy-MM-dd HH:mm:ss,SSS} [%t] %-5p %c %x - %m%n" | 46 | 82 | 72 | 94 |
PatternLayout "%l - %m%n" | 241 | 317 | 299 | 251 |
PatternLayout "%C.%M.%L - %m%n" | 267 | NA | NA | NA |
The results of the measurements (should) show that:
ISO8601DateFormat
instead of the standard SimpleDateFormat
because of its poor performance. See
the %d conversion character in PatternLayout
.
AsyncAppender
does not automatically
increase performance. On the contrary, it significantly degrades
performance. The performance tests done here very quickly fill up
the bounded buffer of the AsyncAppender
and there is
cosiderable overhead in managing this bounded buffer.
On the other hand, had we interleaved logging operations with
long blocking and non CPU-intensive operations, such as I/O,
network access, sleeping threads, then the
AsyncAppender
would have tremendously reduced the cost
of logging in terms of overall application runtime.
In a variant of this test, we have inserted a short sleep
operation between every 10 log operations. When the total slept
time is substracted, logging with the AsyncLogger
takes no time at all. In other words, logging is done for "free".
Constructor Summary | |
Logging()
|
Method Summary | |
static void |
main(String[] argv)
Usage: java org.apache.log4j.performance.Logging confFile runLength [delay] [burstLen]
confFile is an XML configuration file and
runLength (integer) is the length of test loop,
delay is the time in millisecs to sleep every
bustLen log requests.
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Logging()
Method Detail |
public static void main(String[] argv)
java org.apache.log4j.performance.Logging confFile runLength [delay] [burstLen]
confFile
is an XML configuration file and
runLength
(integer) is the length of test loop,
delay
is the time in millisecs to sleep every
bustLen
log requests.
This application just prints the average time it took to log.
|
Log4j 1.2.7 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |