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

Write a simple option parser for pattern converters

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.2.11
    • Other
    • None

    Description

      There isn't a standard way of passing in more than just a single value into pattern converters:

      %logger

      {2}

      Create a simple parser that can split out the Option string:

      public class RepeatConverter : PatternConverter
      {
      protected override void Convert(TextWriter writer, object state)

      { SimpleOptionParser optionParser = new SimpleOptionParser(Option); char character = optionParser.GetChar("Character"); int repeat = optionParser.GetInt("Repeat", 1); // defaults to 1 writer.Write(new String(character, repeat)); }

      }

      Where the pattern might look something like this in the config file:

      %repeat

      {Character:a,Repeat,10}

      that would be translated into:

      aaaaaaaaaa

      Are there more established ways of encoding multiple values in a string?

      %repeat

      {character:a;repeat:10}

      %repeat

      {character=a:char,repeat=10:int}

      ???

      Maybe this will allow the next next version of log4net to support nested patterns...

      Attachments

        Activity

          People

            Unassigned Unassigned
            ron liu ron
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: