https://issues.apache.org/bugzilla/show_bug.cgi?id=45368





--- Comment #3 from Curt Arnold <[EMAIL PROTECTED]>  2008-08-14 08:37:34 PST ---
I think your situation might be better addressed by a combination of LogMF from
the extras companion (with possible enhancements for deferring construction of
messages that require evaluating Object.toString()), the long dormant
MultiFileAppender project and use of message objects that can delay evaluation
until message formatting.  Those should not require changes to the core log4j
API and should offer similar performance to your approach.

If your performance issue is the unnecessary evaluation of functions in the
message parameter, you can delay those evaluations until message layout time by
passing a class whose toString() evaluates the expensive function.

private static class LogIndexEvaluator {
    private final MyClass obj;
    public LogIndexEvaluator(MyClass o) {
        if (o == null) {
           throw NullPointerException();
        }
       obj = o;
    }
    public String toString() {
       return String.valueOf(o.logIndex());
    }
}

....


if (log.isDebugEnabled()) {
    log.debug(new LogIndexEvaluator(this));
}

Construction of a small short lived object is pretty inexpensive in modern
JVM's.


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

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

Reply via email to