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 Scott Deboy <sc...@gmail.com> on 2010/03/28 01:41:30 UTC

NameAbbreviator

I'd like to define a conversion pattern that would take:

org.apache.log4j.package1.package2.package3.classname

and output

package1.package2.package3.classname

Using some pattern like %p{3}

Basically stripping off the leading 3 package names..

I see that the NameAbbreviator class is the right place to add this
capability, but was hoping someone (Curt?) could give me a quick pointer on
how to go about it (or is this already possible with an already-existing
NameAbbreviator implementation?)

Scott

Re: NameAbbreviator

Posted by Scott Deboy <sc...@gmail.com>.
Great!  Thanks.

Scott



On Mar 27, 2010, at 7:03 PM, Curt Arnold <ca...@apache.org> wrote:

>
> On Mar 27, 2010, at 7:41 PM, Scott Deboy wrote:
>
>> I'd like to define a conversion pattern that would take:
>>
>> org.apache.log4j.package1.package2.package3.classname
>>
>> and output
>>
>> package1.package2.package3.classname
>>
>> Using some pattern like %p{3}
>>
>> Basically stripping off the leading 3 package names..
>>
>> I see that the NameAbbreviator class is the right place to add this  
>> capability, but was hoping someone (Curt?) could give me a quick  
>> pointer on how to go about it (or is this already possible with an  
>> already-existing NameAbbreviator implementation?)
>>
>> Scott
>
> %c{3} is used to output the last three elements of a name.  I've  
> enhanced NameAbbreviator to recognize %c{-3} to drop three elements  
> off the name on bug 49010.  The Javadoc for EnhancedPatternLayout  
> did not hint at the other capabilities of NameAbbreviator and still  
> had PatternLayout's @since tag, so I updated those at the same time.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-dev-help@logging.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Re: NameAbbreviator

Posted by Curt Arnold <ca...@apache.org>.
On Mar 27, 2010, at 7:41 PM, Scott Deboy wrote:

> I'd like to define a conversion pattern that would take:
> 
> org.apache.log4j.package1.package2.package3.classname
> 
> and output
> 
> package1.package2.package3.classname
> 
> Using some pattern like %p{3}
> 
> Basically stripping off the leading 3 package names..
> 
> I see that the NameAbbreviator class is the right place to add this capability, but was hoping someone (Curt?) could give me a quick pointer on how to go about it (or is this already possible with an already-existing NameAbbreviator implementation?)
> 
> Scott

%c{3} is used to output the last three elements of a name.  I've enhanced NameAbbreviator to recognize %c{-3} to drop three elements off the name on bug 49010.  The Javadoc for EnhancedPatternLayout did not hint at the other capabilities of NameAbbreviator and still had PatternLayout's @since tag, so I updated those at the same time.


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org