• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Printing method name using log4j

 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

When I use JDK logger it prints the method name from the log is coming from but I have noticed that lo4j does not print the method name. How do I print the method name using lo4j?

Thanks
Pradeep
 
Pavan Panduga
Ranch Hand
Posts: 68
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pradeep,

Have you tried M option for your layout?

It outputs the method name where the logging request was issued. But this may have some performance overhead.


Regards,
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried M option for your layout?


Thanks Pavan! Could you please tell me how to use the M option?
 
Pavan Panduga
Ranch Hand
Posts: 68
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pradeep,
for example like this:



please see PatternLayout javadoc for more options.
[ August 13, 2004: Message edited by: Pavan Kumar Panduga ]
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Pavan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic