[
https://issues.apache.org/jira/browse/LOG4NET-147?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12589627#action_12589627
]
Ron Grabowski commented on LOG4NET-147:
---------------------------------------
Is there a reason why you can't use ILog.DebugFormat? It has a "safer"
String.Format that doesn't throw exceptions if a malformed format is passed in.
> Logging method overloads with string formatting
> -----------------------------------------------
>
> Key: LOG4NET-147
> URL: https://issues.apache.org/jira/browse/LOG4NET-147
> Project: Log4net
> Issue Type: Improvement
> Components: Other
> Reporter: Manuel Riezebosch
> Priority: Minor
>
> I've written some extension methods to support logging with string formatting
> which would be a nice feature to include in the framework.
> namespace log4net
> {
> /// <summary>
> /// Some usefull extensions on log4net
> /// </summary>
> public static class log4netExtensions
> {
> /// <summary>
> /// Log at level Debug
> /// </summary>
> /// <param name="log">The type that is extended.</param>
> /// <param name="message">A composite format string.</param>
> /// <param name="args">An System.Object array containing zero or more
> objects to format.</param>
> public static void Debug(this ILog log, string message, params
> object[] args)
> {
> log.Debug(string.Format(message, args));
> }
> /// <summary>
> /// Log at level Error
> /// </summary>
> /// <param name="log">The type that is extended.</param>
> /// <param name="message">A composite format string.</param>
> /// <param name="args">An System.Object array containing zero or more
> objects to format.</param>
> public static void Error(this ILog log, string message, params
> object[] args)
> {
> log.Error(string.Format(message, args));
> }
> /// <summary>
> /// Log at level Info
> /// </summary>
> /// <param name="log">The type that is extended.</param>
> /// <param name="message">A composite format string.</param>
> /// <param name="args">An System.Object array containing zero or more
> objects to format.</param>
> public static void Info(this ILog log, string message, params
> object[] args)
> {
> log.Info(string.Format(message, args));
> }
> /// <summary>
> /// Log at level Warn
> /// </summary>
> /// <param name="log">The type that is extended.</param>
> /// <param name="message">A composite format string.</param>
> /// <param name="args">An System.Object array containing zero or more
> objects to format.</param>
> public static void Warn(this ILog log, string message, params
> object[] args)
> {
> log.Warn(string.Format(message, args));
> }
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.