If you are worried about said method being removed, don't worry.  But you should reference it via the Logger class.  Logger and Level replace Category and Priority.  But even if you were to reference it with the deprecated classes, you'll have no problems.  They will never be removed as Log4j-1.2.x won't ever be significantly changed.  Only bugfixes and maybe minor features will be applied.

All new development is occurring in the Log4j2 [2] codebase, but it's still in alpha for now.

[2] http://loggingtest.apache.org/log4j/2.x/


Jake

On Thu, 5 Jul 2012 21:15:32 +0000
 "Sira, Amardeep" <[email protected]> wrote:
Hi,

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.

Thanks.

Amardeep



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to