Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get condensed logging 'spring style'

Tags:

java

logging

Our logs, like most logs, get a bit verbose and most of that noise includes the fqcn of the class that did the logging.

I would like to have it log just the first letter of each package/subpackage until it gets to the class.

Example

com.mycompany.client.magensa.MockMagensaClient

Under normal circumstances this would log as:

c.v.c.m.MockMagensaClient

I can obviously write a custom logger but I am certain there is one I can already use. As I don't even know what this style is I am at a loss for what I am even looking for.

Anyone just wanna say: "Oh, you're looking at ... and you can find it ..."?

like image 603
Christian Bongiorno Avatar asked Nov 18 '25 16:11

Christian Bongiorno


1 Answers

If you are familiar with log4j I would use use logback:

http://logback.qos.ch/

http://logback.qos.ch/manual/layouts.html#conversionWord

EDIT:

Apparently also supported in log4j:

http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/EnhancedPatternLayout.html

like image 190
Arjun Sol Avatar answered Nov 20 '25 06:11

Arjun Sol



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!