[logback-dev] [JIRA] Commented: (LBCORE-90) RollingFileAppender calls triggeringPolicy.isTriggeringEvent(activeFile, event) with the same activeFile

Valery Shorin (JIRA) noreply-jira at qos.ch
Mon Jul 27 14:06:11 CEST 2009


    [ http://jira.qos.ch/browse/LBCORE-90?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=11252#action_11252 ] 

Valery Shorin commented on LBCORE-90:
-------------------------------------

Hi Ceki,
Conditions of rollover are: if log file size>maxFileSize ||  once per day || event.getMarker() contains "rotate" marker.
It's my isTriggeringEvent() method (previous version)
    @Override
    public boolean isTriggeringEvent(File activeFile, LoggingEvent event) {
        Marker marker = event.getMarker();
        // activeFile should be checked here, but RollingFileAppender always
        // calls this method with the same activeFile
        File active = new File(getActiveFileName());
        if (active.length() > maxFileSize
                || System.currentTimeMillis() > lastCheck + period
                || marker != null && marker.contains(LogConstants.rotateMarker)) {
            lastElapsedCheck = lastCheck;
            lastCheck = System.currentTimeMillis();
            return true;
        }
        return false;
    }

But "File active = new File(getActiveFileName());   if (active.length() > maxFileSize"  construction is performance bootleneck, and this method is changed as follows:

    @Override
    public boolean isTriggeringEvent(File activeFile, LoggingEvent event) {
        Marker marker = event.getMarker();
        if (bytesWritten > maxFileSize
                || System.currentTimeMillis() > lastCheck + period
                || marker != null && marker.contains(LogConstants.rotateMarker)) {
            lastElapsedCheck = lastCheck;
            bytesWritten = 0;
            lastCheck = System.currentTimeMillis();
            return true;
        }
        return false;
    }

Where "bytesWritten" field is changed from Layout.doLayout(..) method:
	public String doLayout(LoggingEvent event) {
               ................................
		parent.getRollingPolicy().bytesWritten(result.length());
		return result;
	} 
It's not convenient, but we have access to logged string only here. 

So, my thoughts regarding this bug: 
1. I think "activeFile" parameter is unnecessary, we can obtain it using getActiveFileName() method.
2. It will be great if more convenient way to obtain information how many bytes are written to active file will be provided.

Thanks,
Valery

> RollingFileAppender calls triggeringPolicy.isTriggeringEvent(activeFile, event) with the same activeFile
> --------------------------------------------------------------------------------------------------------
>
>                 Key: LBCORE-90
>                 URL: http://jira.qos.ch/browse/LBCORE-90
>             Project: logback-core
>          Issue Type: Bug
>          Components: Appender
>    Affects Versions: 0.9.14
>            Reporter: Valery Shorin
>            Assignee: Ceki Gulcu
>
> In subAppend(...) method RollingFileAppender calls triggeringPolicy.isTriggeringEvent(activeFile, event) method with activeFileCache variable as first parameter, but activeFileCache variable initialized in start() method of RollingFileAppender and not changed anymore.

-- 
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