Logger.xxxFormat() methods instead of String.Format()

Topics: Logging Application Block
Feb 11, 2014 at 4:18 PM
Hi there,

Are there any plans to add InfoFormat, DebugFormat, ErrorFormat methods similar to log4net's? It would be great to pass a format and a list of parameters to such method rather than using the complex Logger.Write(String.Format(...., .., ..)) statements in the code.

Feb 12, 2014 at 5:04 AM
I assume you are talking about formatting of the Message property and not the entire LogEntry (which uses a formatter).

I don't know of any plans to add this functionality. I'm not sure I'm a huge fan of having the Severity in the method name but I do like the idea of being able to pass a lambda representing a format String expression for the Message property.

You can add an entry to the Work List at the Logging Application Block site: https://lab.codeplex.com/workitem/list/basic . Note that community contributions are now open so it's possible for to add functionality (although there is still an approval process).

If you really like the log4net interface you can also consider using Common Logging which has an API similar to log4net and has adapters for many different logging frameworks (including Enterprise Library).

Another approach is to consider using the Semantic Logging Block where you can craft your own logging interface where each logging method exposes the appropriate parameters and can format them as required.

Randy Levy
Enterprise Library support engineer
Support How-to
Marked as answer by DashNY on 3/4/2014 at 6:02 AM
Mar 4, 2014 at 2:03 PM
Thanks Randy. Common Logging library worked out well for me.