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=43204>.
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=43204

           Summary: Contribution Java 5+ Improvements: String formatter,
                    stack trace inspection
           Product: Log4j
           Version: unspecified
          Platform: Other
        OS/Version: other
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Other
        AssignedTo: [email protected]
        ReportedBy: [EMAIL PROTECTED]


I wrote a small enhancement to log4j that takes advantage of two useful Java
APIs: String.formatter to avoid creating garbage strings when a logger isn't
enabled and the ability to use a management factory to programmatically get
stack traces to avoid boilerplate code. I have implemented this as a decorator
(LogFormatter). E.g.,

public static class MyClass {
    public LogFormatter formatter = LogFormatter.get();

    public void myMethod(int foo) {
        formatter.debug("The value %d was received", foo);
        try {
            something();
        } catch (MyException e) {
            formatter.error(e, "Failure for %d", foo);
        }
    }
}

See attached code. Please feel free to reuse or incorporate this if you like any
of these features.

-- 
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to