Log4net
  1. Log4net
  2. LOG4NET-77

A small improvement of log4net.Layout.Pattern.ExceptionPatternConverter - added 'Option' propery support

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.2.10
    • Fix Version/s: 1.2.11
    • Component/s: None
    • Labels:
      None

      Description

      A small improvement of log4net.Layout.Pattern.ExceptionPatternConverter - added 'Option' propery support
      Example of usage:
      <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender" >
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%exception

      {TargetSite}

      - %exception

      {Message}

      %newline" />
      </layout>
      </appender>

        Activity

        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        74d 19h 22m 1 Ron Grabowski 29/Jul/06 20:18
        Ron Grabowski made changes -
        Fix Version/s 1.2.11 [ 12310980 ]
        Ron Grabowski made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Hide
        Ron Grabowski added a comment -

        Fixed in 426832.

        Show
        Ron Grabowski added a comment - Fixed in 426832.
        Hide
        Nicko Cadell added a comment -

        For consistency i would go for SystemInfo.NullText

        Show
        Nicko Cadell added a comment - For consistency i would go for SystemInfo.NullText
        Hide
        Ron Grabowski added a comment -

        Which one of the two Assert statements are correct? StackTrace is null.

        [Test]
        public void TestExceptionPattern()
        {
        StringAppender stringAppender = new StringAppender();
        PatternLayout layout = new PatternLayout("%exception

        {stacktrace}

        ");
        stringAppender.Layout = layout;

        ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
        BasicConfigurator.Configure(rep, stringAppender);

        ILog log1 = LogManager.GetLogger(rep.Name, "TestExceptionPattern");

        Exception exception = new Exception("Oh no!");
        log1.Info("TestMessage", exception);

        /* From ExceptionPatternConverter.cs:
        If there is no exception then nothing will be output
        and no trailing newline will be appended.
        It is typical to put a newline before the exception
        and to have the exception as the last data in the pattern.
        */

        // ???
        Assert.AreEqual(string.Empty, stringAppender.GetString());

        // ???
        Assert.AreEqual(SystemInfo.NullText, stringAppender.GetString());

        stringAppender.Reset();
        }

        Show
        Ron Grabowski added a comment - Which one of the two Assert statements are correct? StackTrace is null. [Test] public void TestExceptionPattern() { StringAppender stringAppender = new StringAppender(); PatternLayout layout = new PatternLayout("%exception {stacktrace} "); stringAppender.Layout = layout; ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString()); BasicConfigurator.Configure(rep, stringAppender); ILog log1 = LogManager.GetLogger(rep.Name, "TestExceptionPattern"); Exception exception = new Exception("Oh no!"); log1.Info("TestMessage", exception); /* From ExceptionPatternConverter.cs: If there is no exception then nothing will be output and no trailing newline will be appended. It is typical to put a newline before the exception and to have the exception as the last data in the pattern. */ // ??? Assert.AreEqual(string.Empty, stringAppender.GetString()); // ??? Assert.AreEqual(SystemInfo.NullText, stringAppender.GetString()); stringAppender.Reset(); }
        Ron Grabowski made changes -
        Hide
        Ron Grabowski added a comment -

        I think its ok to just support just the 5 public properties on the Exception object.

        Show
        Ron Grabowski added a comment - I think its ok to just support just the 5 public properties on the Exception object.
        Ron Grabowski made changes -
        Assignee Ron Grabowski [ ron ]
        Imrich Olha made changes -
        Component/s Other [ 11606 ]
        Description A small imrovement of log4net.Layout.Pattern - added 'Option' propery support
        Example of usage:
            <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender" >
              <layout type="log4net.Layout.PatternLayout">
                <conversionPattern value="%exception{TargetSite} - %exception{Message}%newline" />
              </layout>
            </appender>
        A small improvement of log4net.Layout.Pattern.ExceptionPatternConverter - added 'Option' propery support
        Example of usage:
            <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender" >
              <layout type="log4net.Layout.PatternLayout">
                <conversionPattern value="%exception{TargetSite} - %exception{Message}%newline" />
              </layout>
            </appender>
        Summary A small imrovement of log4net.Layout.Pattern - added 'Option' propery support A small improvement of log4net.Layout.Pattern.ExceptionPatternConverter - added 'Option' propery support
        Imrich Olha made changes -
        Field Original Value New Value
        Attachment ExceptionPatternConverter.cs [ 12331913 ]
        Imrich Olha created issue -

          People

          • Assignee:
            Ron Grabowski
            Reporter:
            Imrich Olha
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development