[ 
https://issues.apache.org/jira/browse/DERBY-6350?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13772197#comment-13772197
 ] 

Brett Bergquist commented on DERBY-6350:
----------------------------------------

I have an implementation to contribute for this feature.  It has the following 
design:

- A RollingFileStream class that extends OutputStream that can be configured 
with a file pattern, file size limit, and file count, and provides the 
functionality to keep track how much has been written to the stream and when 
the max is reached, close the stream, roll the files, and reopen the stream 
redirected to the newest file.  This is heavily borrowed from 
java.logger.FileHandler for the file handling capability.

- A RollingFileStreamProvider class that provides a static method to configure 
and return an instance of RollingFileStream.  derby.properties is consulted for 
the file pattern, file size limit, and file count.  If these are not present, 
then built in defaults are used which configure the pattern such that files 
"derby-n.log" are created in DERBY_HOME, with the maximum file size of 1Mb and 
a maximum of 10 files.

This can be plugged into the existing framework of redirecting the error 
stream.  The derby.properties can be set as:

derby.stream.error.method=org.apache.derby.impl.services.stream.RollingFileStreamProvider.getOutputStream
derby.stream.error.rollingfile.pattern=%d/db-%g.log
derby.stream.error.rollingfile.limit=2048000
derby.stream.error.rollingfile.count=5

Note that the "derby.infolog.append" is still honored.  If set to "false", then 
when Derby starts, the log files are rolled immediately and a log file is used. 
 If set to "true", then when Derby starts, the existing newest log file (if 
any) is appended to.




                
> Provide a rolling file implementation of derby.log
> --------------------------------------------------
>
>                 Key: DERBY-6350
>                 URL: https://issues.apache.org/jira/browse/DERBY-6350
>             Project: Derby
>          Issue Type: Improvement
>          Components: Miscellaneous
>            Reporter: Brett Bergquist
>            Priority: Minor
>              Labels: features
>
> By default, derby.log grows without bounds if the derby.infolog.append 
> property is set to "true".   Setting this to "true" helps in a hands off 
> production environment to ensure that if Derby restarts, the derby.log which 
> might contain important information is not lost.  On the other hand, when set 
> the "true" the derby.log grows without bounds.  This is problematic in a long 
> running system.  
> What is really needed is the ability to have a rolling derby.log file support 
> where the maximum file size and maximum number of files can be specified.  
> Derby has the ability to configure the location of the log file (ie. 
> derby.stream.error.file) and also two methods of redirecting the error stream 
> (.ie derby.stream.error.method and derby.stream.error.field).  There is no 
> standard implementation that supports a rolling derby.log however.
> This facility should be part of the core Derby system so that it works in 
> both embedded and network server models.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to