I would like to know how to print the method name being invoked using the log4j API. The conversion pattern %L displays the file name only and not the method.
Please give the solution for this.
There is no general solution for this. Java provides no simple way to determine the calling method. The best way to do this is:
a) Pass in the method name as part of the logged method.
b) Print out an exception stacktrace, which will include the method name.
As you indicated, the %M pattern as indicated in the log4j manual works out.
Thanks for your help.
The point that i observed is that,
%M - method name
%C- Class name