You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Lethin, Doug" <Do...@Intuit.com> on 2003/10/14 16:51:43 UTC
need functionality to truncate the tail of fields using
PatternLa yout
I'm migrating my application to log4j and need to define a message format
that's compatable with an output already in place from my original logging
code. There are two formats I can't currently seem to do:
1. I need to output the timestamp field as a two letter day of week string
-- Mo, Tu, We, etc.
2. I need to output the priority field as one character - D, I, W, E, F
It seems the formatting directives don't allow for this. They allow you to
truncate fields to a max value, but they're truncated from the front, such
that the directive '%.1p will truncate Info to 'o' and not 'I'
I looked through the latest log4j code, and found a way to patch this
functionality in by adding another formatting directive similar to the '.'
but using a '#' instead.
It will similarly define the max length for a field, BUT it will truncate
the trailing characters rather than the leading characters.
Examples:
%d{E} -> Tuesday
%.2d{E} -> ay
%#2d{E} -> Tu
%p -> INFO
%.1p -> O
%#1p -> I
In order to do this, I needed to make minor patches to 3 files:
- org.apache.log4j.helpers.FormattingInfo.java
- org.apache.log4j.helpers.PatternConverter.java
- org.apache.log4j.helpers.PatternParser.java
I'd be happy to submit these patches in the hopes that this functionality
could be added to the code base.
I'm assuming all I need to do is send mail to this list with the subject
PATCH, or [PATCH], and then include in the message the three diff -c
outputs?
Is this kind of functionality useful to others?
Is this the approach I should be taking when proposing changes?
Thanks in advance.
Doug
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-dev-help@jakarta.apache.org