This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Other Open Source Projects and the fly likes Printing method name using log4j Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Reply Bookmark "Printing method name using log4j" Watch "Printing method name using log4j" New topic
Author

Printing method name using log4j

Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8876

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


Groovy
Pavan Panduga
Ranch Hand

Joined: Jun 12, 2002
Posts: 68
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

Joined: Feb 27, 2002
Posts: 8876

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

Joined: Jun 12, 2002
Posts: 68
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

Joined: Feb 27, 2002
Posts: 8876

Thanks Pavan
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Printing method name using log4j
 
Similar Threads
how to add LOG function in richfaces
Clarification on init() method of HttpServlet
log4j vs commons logging
Log4j error while deploying EJB 3.0 in weblogic 10
How to get java class name and method name and print it from the method