On 10/15/2010 5:53 AM, Thorsten Schöning wrote:
Hello,
is there any way to get the method name of the logging caller in the
log message?
As you say, the log4j docs document %M in the PatternLayout (while
log4cxx does not) but caution against the inefficiency of it's use.
Additionally "The Complete Log4J Manual" (a good document to have)
points out that even in Java this information can be discarded by the
compiler.
In log4cxx %F and %L provide the file name and line number
respectively, but that is because they can rely on the ubiquitious
__FILE__ and __LINE__ macros. The LOG4CXX_LOCATION macro is documented
to use __LOG4CXX_FUNC__ with a value of "".
If your compiler and flags support __FUNCTION__, you could work that
into your message or change the definition of __LOG4CXX_FUNC__ and go
on to implement %M.
I haven't even glanced at the code to see where that's at. I just
inflexibly typed the function name into a DEBUG message near the top
of the message call, or sometimes used a NDC to track the call stack
in debug logs.
Good luck,
--
Jacob Anawalt
Gecko Software, Inc.
janaw...@geckosoftware.com
435-752-8026