Automatically log classname?

Topics: Logging Application Block
Jan 8, 2008 at 12:39 PM
Hi - is it possible to have information regarding classname and method name automatically included in the output to the log? Is there some sort of configuration value to enable this?
Jan 8, 2008 at 2:28 PM
Hi Peter,

You can get a stack trace with most TraceListeners, but not when you specify a text formatter; this feature is available through configuration.
You can also use the DebugInformationProvider (described in topic "Populating a Log Message with Additional Context Information" in the help file) but it's not used through configuration and requires some programming effort.

You could extend the TextFormatter to expose a new token for this specific information you want.

Jan 9, 2008 at 8:02 AM
OK, thanks for the info. It is a shame it seems so hard to get this info, as it would seem quite useful (log4net out-of-the-box can be configured to output class and method name, and I use that function all the time).

Anyway, even if I set "IncludeCallStack=true", I do not get any stack info in my output file. So I'll have to investigate a little more into customising logging if we decide we really want this info.

I wonder what is the use of policy-injection logging, because all you can get is a message like "before the method call" or "after the method call" - but you have no idea what method!