0
votes

When I used the Info or Debug methods of log4net it logs the method name as one of the fields.

However, when I use the InfoFormat or any of the other format methods, it does not log the method name. Is it possible to log the method name as well, using the format methods? If so, how?

Presently, it just fills that column with a question mark.

Edit: A line in the log looks like

INFO 2015-04-11 02:30:45,254 2074ms className ? - Some logging info

It contains the following information:

1.Debugging level

2.Date

3.Time

4.Time since program began execution

5.Class Name

6.Method name - This is displaying a question mark. I want it to display the method name

7.Logging information

1
Please show your configstuartd
@stuartd I am also facing same problem. Problem is that I don't get method name when using DebugFormat(..) while I am getting it in using Debug(..)Kamran Shahid

1 Answers

-1
votes

In your pattern layout you can access the method name with the %M (note uppercase) or %method variables. See the PatternLayout documentation for a list. It's worth noting, that using location info variables can be slow.