You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wrote a custom RollingPolicy based on the FixedWindowRollingPolicy for my app and combined it with the SizeBasedTriggeringPolicy. During testing I noted that the rollover never occurred. However, the base logfile (client.log) was created and filled. Further investigation of the problem revealed that the FixedWindowRollingPolicy seems to be affected by #30. As soon as I override the getActiveFIleName method in my RollingPolicy like so
/**
* Gets the absolute path to the filename, starting from the app's
* "files" directory
*
* @param filename filename to evaluate
* @return absolute path to the filename
*/
private String getAbsoluteFilePath(String filename) {
// In Android, relative paths created with File() are relative
// to root, so fix it by prefixing the path to the app's "files"
// directory.
String dataDir = context.getProperty(CoreConstants.DATA_DIR_KEY);
return FileUtil.prefixRelativePath(dataDir, filename);
}
@Override
public String getActiveFileName() {
return getAbsoluteFilePath(super.getActiveFileName());
}
everything works as expected. I can provide a patch, but I don't know where to do the fixing. Should the RollingFileAppender fix the path received from the RollingPolicy or should the path returned by the RollingPolicy be already correct?
For reference here is the appender configuration I used:
<appender name="MyCustomAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- the current logfile name -->
<file>client.log</file>
<rollingPolicy class="MyCustomRollingPolicy">
<fileNamePattern>client.%i.log</fileNamePattern>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<!-- small logfile size used for testing -->
<maxFileSize>10</maxFileSize>
</triggeringPolicy>
<encoder>
<pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
</encoder>
</appender>
The text was updated successfully, but these errors were encountered:
fberlakovich
changed the title
SIzeBasedTriggeringPolicy fails for relative file paths
SizeBasedTriggeringPolicy fails for relative file paths
Nov 30, 2016
To be consistent with FileAppender, which changes the relative path to absolute, I think the path fix should be in RollingFileAppender (instead of the RollingPolicy).
Note the wiki currently indicates the absolute file paths should be specified for both FileAppender and RollingFileAppender.
I wrote a custom RollingPolicy based on the
FixedWindowRollingPolicy
for my app and combined it with theSizeBasedTriggeringPolicy
. During testing I noted that the rollover never occurred. However, the base logfile (client.log) was created and filled. Further investigation of the problem revealed that theFixedWindowRollingPolicy
seems to be affected by #30. As soon as I override thegetActiveFIleName
method in my RollingPolicy like soeverything works as expected. I can provide a patch, but I don't know where to do the fixing. Should the RollingFileAppender fix the path received from the RollingPolicy or should the path returned by the RollingPolicy be already correct?
For reference here is the appender configuration I used:
The text was updated successfully, but these errors were encountered: