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 "Schudt, Christian" <Ch...@cgm.com> on 2015/12/03 13:11:33 UTC

Log4j 2 Conversion Pattern + negative precision

Hello,

log4j 1 has the possibiliy to specify a negative precision for the logger name in the pattern, e.g.:

c{-4}

which meant, that the 4 left most package names were excluded.

E.g. "org.apache.logging.log4j.core.LogEvent" becomes "core.LogEvent"

In Log4j2, this pattern results in:

"-.-.-.-.core.LogEvent"

How can I achieve the log4j 1 behavior, i.e. excluded the first X package names?

Thanks,
Christian

Related documentation:
http://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout

Re: Log4j 2 Conversion Pattern + negative precision

Posted by Gary Gregory <ga...@gmail.com>.
In Log4j2, you can use %c{2} to _include_ the rightmost 2 packages. See the
docs you point to...

Gary

On Thu, Dec 3, 2015 at 4:11 AM, Schudt, Christian <Ch...@cgm.com>
wrote:

> Hello,
>
> log4j 1 has the possibiliy to specify a negative precision for the logger
> name in the pattern, e.g.:
>
> c{-4}
>
> which meant, that the 4 left most package names were excluded.
>
> E.g. "org.apache.logging.log4j.core.LogEvent" becomes "core.LogEvent"
>
> In Log4j2, this pattern results in:
>
> "-.-.-.-.core.LogEvent"
>
> How can I achieve the log4j 1 behavior, i.e. excluded the first X package
> names?
>
> Thanks,
> Christian
>
> Related documentation:
> http://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout
>



-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory