Uploaded image for project: 'Log4net'
  1. Log4net
  2. LOG4NET-147

Logging method overloads with string formatting

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Invalid
    • None
    • None
    • Other
    • None

    Description

      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)); }

      }
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            riezebosch Manuel Riezebosch
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: