Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-208

Add a pattern resolver to <file> property of FileAppnder

    XMLWordPrintable

Details

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • None
    • logback-core
    • None
    • Ubuntu 8.04, J2SE 6

    Description

      Following discussion on the mailing list, it would be very convenient to be able to use patterns in the filename of a FileAppender. My initial expectation was to be able to do something like:

      <appender name="myFileAppender" class="ch.qos.logback.core.FileAppender">
      <file>${logFolder}/SomePrefix.%d.someExt</file>
      [...]
      </appender>

      where %d would be substituted by the current date. However Ralph Goers, when replying to my question on the mailing list, suggested a more flexibl approach:

      <appender name="myFileAppender" class="ch.qos.logback.core.FileAppender">
      <File resolver="com.mycorp.logback.MyPatternResolver">someName.%

      {host}

      .%

      {datetime}

      .log</File>
      [...]
      </appender>

      with MyPatternResolver implementing an interface like:

      package ch.qos.logback.core.pattern;

      public interface Resolver

      { String resolve(String pattern); }

      Providing a default implementation allowing to generate timestamp, use system properties, would be nice too.

      Currently this can be done programmatically, but it would be most convenient to have the possibility to do this using the Joran configurator.

      Best regards,
      Nicolas

      Attachments

        Activity

          People

            logback-dev Logback dev list
            ngiraud Nicolas Giraud
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: