[logback-dev] [JIRA] Commented: (LBCLASSIC-84) Backslashes (Windows) cause issues with rolling

Mike Boyers (JIRA) noreply-jira at qos.ch
Tue Nov 11 19:06:21 CET 2008


    [ http://jira.qos.ch/browse/LBCLASSIC-84?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=10896#action_10896 ] 

Mike Boyers commented on LBCLASSIC-84:
--------------------------------------

Sorry I didn't provide initially - using version 0.9.9.

Config code is as follows.  This is the start() method for a class that extends RollingFileAppender:

    public void start() {
        
        // Determine the filename and location
        if (this.fileName == null) {
         // If they didn't specify a filename, we'll determine it ourselves
            this.fileName = NPlatform.getAppLogFileName();
        } else if (!this.fileName.contains(File.separator)) {
            // If we were given a file without the path, determine the path
            this.fileName = NPlatform.getAppLogDir() + this.fileName;
        }
        
        // Since we've assumed responsibility of determining the filename and location, we'll
        // also assume responsibility of instantiating and configuring the rolling objects.
        FixedWindowRollingPolicy rollingPolicy = new FixedWindowRollingPolicy();
        rollingPolicy.setContext(this.getContext());
        rollingPolicy.setMinIndex(1);
        rollingPolicy.setMaxIndex(20);
        rollingPolicy.setParent(this);
        String pattern = this.getFileNamePatternFromFileName(this.fileName);
        rollingPolicy.setFileNamePattern(pattern);
        this.setRollingPolicy(rollingPolicy);
        rollingPolicy.start();
        
        SizeBasedTriggeringPolicy triggeringPolicy = new SizeBasedTriggeringPolicy();
        triggeringPolicy.setMaxFileSize("1MB");
        this.setTriggeringPolicy(triggeringPolicy);
        triggeringPolicy.start();
        
        super.start();
    }

The static calls to NPlatform are used to determine the location of the logfile, I want to put it in the appropriate place for all operating systems.  On most operating systems, this will be something like ~/Library/Logs/, but for windows, this value will look something like: C:\Documents and Settings\Mike\Application Data\MyAppName\logs\appname.log

I hope this helps, please let me know if you need more information.  I should also note that I have not tried this with version 0.9.11, but would be happy to if you think it would help.

> Backslashes (Windows) cause issues with rolling
> -----------------------------------------------
>
>                 Key: LBCLASSIC-84
>                 URL: http://jira.qos.ch/browse/LBCLASSIC-84
>             Project: logback-classic
>          Issue Type: Bug
>    Affects Versions: unspecified
>         Environment: Windows
>            Reporter: Mike Boyers
>            Assignee: Logback dev list
>
> This may be a duplicate of LBCLASSIC-56, but I wasn't sure, so I went ahead and created this issue.
> On windows, my logs failed to roll when I used a "windows-looking" absolute path when calling the rolling policy's setFileNamePattern() method.  If I use forward slashes instead of backwards slashes, it works fine.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the logback-dev mailing list