logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <ralph.go...@dslextreme.com>
Subject Re: Changing %c logger abbrevation - can't figure out how to achieve what I'm after
Date Tue, 07 Aug 2018 22:59:23 GMT
You want to look at the NameAbbreviator class. It has sub-classes that perform the various
styles of abbreviation.

Logback also has a name abbreviator where you specify a max length. Basically, the algorithm
is, a) always print the full class name, b) if the length is large enough to contain the first
letter of all the package names, include them, c) if the length is large enough expand the
last package name to its full length, d) repeat c for each right-most package until the length
would be exceeded.

Following this pattern you might be able to achieve what you are looking for. Unfortunately,
the syntax Logback uses is exactly the same for what we use for the number of items. To solve
this I would probably use a syntax like {length(10)} to use the algorithm above and create
a MaxLengthAbbreviator.

For the specific syntax you are asking for, essentially you are trying to declare the number
of right-most packages that you want expanded with all the others being a single character.
So for that the syntax could be {right(1)}.

Mind you, these are just ideas. If you can come up with better algorithms or pattern syntax,
have at it!

Ralph



> On Aug 7, 2018, at 1:55 PM, Shawn Heisey <apache@elyograg.org> wrote:
> 
> On 8/7/2018 9:43 AM, Remko Popma wrote:
>> Feel free to submit a patch/pull request with unit tests! ;-)
> 
> I will open an issue.  I can certainly attempt a patch, but I can't make
> any guarantees.  I have to *understand* the code before I can modify it!
> Since I have never looked at log4j code, I expect the road to
> understanding will not be short.
> 
> What recommendations do you have about the precision specifier syntax to
> achieve output like o.a.s.c.SolrCore.Request?
> 
> Thanks,
> Shawn
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> 



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


Mime
View raw message