You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by "Lethin, Doug" <Do...@Intuit.com> on 2003/10/16 17:57:59 UTC
RE: need functionality to truncate the tail of fields using
Patte rnLa yout
Wow, thanks for the fast response from the man himself.
I'm a bit baffled, though, as I thought what I had was the latest release,
version 1.2.8, which doesn't seem to have the enhancements you mention. I'm
guessing this is because its in the currently cvs code which I would need to
get, rather than get the released version?
Thanks again.
doug
> -----Original Message-----
> From: Ceki Gülcü [mailto:ceki@qos.ch]
> Sent: Thursday, October 16, 2003 11:45 AM
> To: Log4J Users List
> Subject: Re: need functionality to truncate the tail of
> fields using PatternLa yout
>
> Doug,
>
> There is no need to patch the files you mention. Actually,
> they don't even exist anymore.
>
> PatternLayout has been modified to accept new conversion
> words. See https://www.qos.ch/logging/PatternLayout.html
> for more details.
>
> I hope this helps,
>
> At 11:24 AM 10/16/2003 -0400, Lethin, Doug wrote:
> >[I sent this message the other day to the dev mailing
> list and got no
> >response. I'm now sending this to the log4j user mailing
> list in case
> >anyone has any feedback for me. Thanks in advance.]
> >
> >I'm migrating my application to use log4j and need to
> define a message
> >format that's compatable with an output format 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 in PatternLayout 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 (original truncate directive)
> > %#2d{E} -> Tu (new truncate directive)
> > %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 dev mailing
> 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-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail:
> log4j-user-help@jakarta.apache.org
>
> --
> Ceki Gülcü
>
> For log4j documentation consider "The complete log4j manual"
> ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp
>
> import org.apache.Facetime;
> ApacheCon US 2003, 18-21 November http://apachecon.com/
>
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org