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

Key: LBCORE-85
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Logback dev list
Reporter: Neil Lott
Votes: 2
Watchers: 2
Operations

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

Allow configuration of timezone with file name pattern

Created: 03/Feb/09 05:54 PM   Updated: 08/Jul/09 09:48 PM
Component/s: Appender
Affects Version/s: 0.9.14
Fix Version/s: None

Environment: Any


 Description  « Hide

<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
           <FileNamePattern>/usr/local/neil/logs/msa-mdn-%i-%d{yyyyMMdd-HHmmss}.log</FileNamePattern> <MinIndex>1</MinIndex>
           <MaxIndex>5</MaxIndex>
 </rollingPolicy>

In this case the filename pattern %d it would be nice to allow configuration of timezone somehow in the pattern.

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
John Crim - 08/Jul/09 09:29 PM
We've implemented this for TimeBasedRollingPolicy by subclassing TimeBasedRollingPolicy and FileNamePattern. In a sublcass of FileNamePattern you can add this to the constructor:
{code}
        Converter<Object> conv = headTokenConverter;
        while (conv != null) {
            if (conv instanceof DateTokenConverter) {
                ((DateTokenConverter) conv).sdf.setTimeZone(timeZone);
            }
            conv = conv.getNext();
        }
{code}

The unfortunate part is that our subclasses had to use the same packages as TimeBasedRollingPolicy and FileNamePattern in order to access the package-scoped fields. This is turn required us to un-seal our jar (I suppose it's good in this case that the logback jars don't come sealed).

I'm going to open a separate issue to request the package-scoped fields be changed to protected.

John Crim - 08/Jul/09 09:48 PM
The issue to enable protected access to rolling and helper fields is LBCORE-108 . It also includes the source code we use to add timezone support to TimeBasedRollingPolicy.