logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sira, Amardeep" <amardeep.s...@etrade.com>
Subject Alternative API for Category.log()
Date Thu, 05 Jul 2012 21:15:32 GMT

Given that the Category and Priority classes are now deprecated, I am looking for an alternative
API for "http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Category.html#log(java.lang.String,
org.apache.log4j.Priority, java.lang.Object, java.lang.Throwable)<http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Category.html#log(java.lang.String,%20org.apache.log4j.Priority,%20java.lang.Object,%20java.lang.Throwable)>".

My usecase consists of the logging being done by a generic helper class. Because of this,
the method name printed in the log file is always that of the wrapper method of this helper
class. The above log() API allows me to pass in the name of the helper class so that the resulting
log prints the name of the actual calling method - as required.

Ex, MyClass.myMethod() needs to log a debug message. It calls MyHelper.debugWrapper(). The
resulting log entry will look like,
DEBUG [Thread-Name] mypkg.MyClass.debugWrapper(): my message string
If, within MyHelper.debugWrapper(), instead of calling logger.debug(), I call log(mypkg.MyHelper,
Priority.DEBUG, myMessage, null), the resulting log entry is,
DEBUG [Thread-Name] mypkg.MyClass.myMethod(): my message string

Kindly assist.



  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message