java - Dropping The First X Parts Of A Logger Name -


I have found a piece of Log4J2 config that looks like this:

   & Lt; / Root & gt; & Lt; / Collections & gt; & Lt; / Configuration & gt;   

And this will print me as login statements:

  10: 49: 55.700 INFO uk.co.ltheobald.myapp.packageA Foo - Hello! 10: 49: 55.800 INFO uk.co.ltheobald.myapp.packageA.Bar - Hello! 10: 49: 55.900 INFO uk.co.ltheobald.myapp.packageA.subpackage.Foo - Hello!   

I would trim down below and would like to remove uk.co.ltheobald.myapp. Part of each line I know that I can set the package level to print most X packages using the % logger {2} , so I get something like this :

  10:49: 55.700 INFO packageA.Foo - Hello! 10: 49: 55.800 INFO packageA. Hi - Hello! 10: 49: 55.900 INFO subpackage.Foo - Hello!   

But this is part of my package nomenclature, as I give the nest class under more package packages.

Surely there should be a way to ignore the first four packages? Something like this % logger {-4} would be nice! Anyone have any clue?

I have just done a test and this pattern has removed 4 first package names:

  & lt; PatternLayout Pattern = "% d {HH: mm: ss.SSS}% -5level% {% logger} {*. *? \ .. *? \ * *? \ * * * * \.} {} -% msg% n "/ & gt;   

You can even use (to reduce the pattern):

  & lt; PatternLayout pattern = "% d {HH: mm: ss.SSS}% - 5level% {% logger} {^ (. *?.) {4}} {} -% msg% n" / & gt;    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -