[logback-dev] Least-effort logging with bytecode modification

Ramon Nogueira ramon at ratendate.net
Sat Jul 26 05:01:26 CEST 2008


At the company I work for we use the same logging pattern almost
everywhere, for example:

public class SomeClass {
	private static final Logger log =

	public void someMethod() {
		log.debug("A log message");

I would like to simplify this to:

import static logging.LogApi.*;

public class SomeClass {
	private void someMethod(String someArg) {
		debug("A log message"); // from static import

And then have code equivalent to the former generated (preferably at
class load time) dynamically. This could save us hundreds of lines of
boilerplate code and provide other interesting options like declarative
rules regarding the "injected" logger name, perhaps through class/method
annotations and pre-calculating the source location information.

I thought of implementing this with AspectJ but its probably easier to
just use ASM directly for such a simple case.

Any ideas/suggestions/precedents?


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://qos.ch/pipermail/logback-dev/attachments/20080726/2c8405ea/attachment.pgp 

More information about the logback-dev mailing list