History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: LBCORE-68
Type: New Feature New Feature
Status: Open Open
Priority: Major Major
Assignee: Logback dev list
Reporter: Nicolas Giraud
Votes: 2
Watchers: 3
Operations

If you were logged in you would be able to see more operations.
logback-core

Add a pattern resolver to <file> property of FileAppnder

Created: 31/Oct/08 09:07 AM   Updated: 03/Feb/09 05:59 PM
Component/s: Appender, Joran
Affects Version/s: 0.9.11
Fix Version/s: None

Environment: Ubuntu 8.04, J2SE 6


 Description  « Hide
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


 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Neil Lott - 03/Feb/09 05:59 PM
I agree with Nicolas and feel this would be a valuable addition to logback.

My suggestion would be that any pattern allowed in the filepattern (e.g. addition of a timezone) should be allowed in the initial filename.

Thanks,

Neil