org.jboss.logmanager.handlers

## Class PeriodicSizeRotatingFileHandler

- java.lang.Object
- - java.util.logging.Handler
  - - org.jboss.logmanager.ExtHandler
    - - org.jboss.logmanager.handlers.WriterHandler
      - - org.jboss.logmanager.handlers.OutputStreamHandler
        - - org.jboss.logmanager.handlers.FileHandler
          - - org.jboss.logmanager.handlers.PeriodicRotatingFileHandler
            - - org.jboss.logmanager.handlers.PeriodicSizeRotatingFileHandler

All Implemented Interfaces:
  Closeable, Flushable, AutoCloseable, FlushableCloseable, Protectable

    public class PeriodicSizeRotatingFileHandler
    extends PeriodicRotatingFileHandler

A file handler which rotates the log at a preset time interval or the size of the log.

The time interval is determined by the content of the suffix string which is passed in to `PeriodicRotatingFileHandler.setSuffix(String)`.

The size interval is determined by the value passed in the `setRotateSize(long)`.

Author:
  James R. Perkins

### Nested Class Summary

### Nested classes/interfaces inherited from class org.jboss.logmanager.handlers.PeriodicRotatingFileHandler

`PeriodicRotatingFileHandler.Period`

### Field Summary

### Fields inherited from class org.jboss.logmanager.handlers.WriterHandler

`outputLock`

### Fields inherited from class org.jboss.logmanager.ExtHandler

`handlers, handlersUpdater`

### Constructor Summary

Constructors
Constructor and Description
`PeriodicSizeRotatingFileHandler()` Default constructor.
`PeriodicSizeRotatingFileHandler(File file, String suffix)` Construct a new instance with the given output file.
`PeriodicSizeRotatingFileHandler(File file, String suffix, boolean append)` Construct a new instance with the given output file and append setting.
`PeriodicSizeRotatingFileHandler(File file, String suffix, long rotateSize, int maxBackupIndex)` Construct a new instance with the given output file.
`PeriodicSizeRotatingFileHandler(File file, String suffix, long rotateSize, int maxBackupIndex, boolean append)` Construct a new instance with the given output file.
`PeriodicSizeRotatingFileHandler(String fileName)` Construct a new instance with the given output file.
`PeriodicSizeRotatingFileHandler(String fileName, boolean append)` Construct a new instance with the given output file and append setting.

### Method Summary

Methods
`boolean` `isRotateOnBoot()` Indicates whether or a not the handler should rotate the file before the first log record is written.
`protected void` `preWrite(ExtLogRecord record)` Execute any pre-write policy, such as file rotation.
`void` `setFile(File file)` Set the output file.
`void` `setMaxBackupIndex(int maxBackupIndex)` Set the maximum backup index (the number of log files to keep around).
`void` `setOutputStream(OutputStream outputStream)` Set the output stream to write to.
`void` `setRotateOnBoot(boolean rotateOnBoot)` Set to a value of `true` if the file should be rotated before the a new file is set.
`void` `setRotateSize(long rotateSize)` Set the rotation size, in bytes.

### Methods inherited from class org.jboss.logmanager.handlers.PeriodicRotatingFileHandler

`getNextSuffix, getTimeZone, setSuffix, setTimeZone`

### Methods inherited from class org.jboss.logmanager.handlers.FileHandler

`getFile, setAppend, setFileName`

### Methods inherited from class org.jboss.logmanager.handlers.OutputStreamHandler

`getEncoding, setEncoding, setWriter`

### Methods inherited from class org.jboss.logmanager.handlers.WriterHandler

`close, doPublish, flush, safeClose`

### Methods inherited from class org.jboss.logmanager.ExtHandler

`addHandler, checkAccess, checkAccess, clearHandlers, disableAccess, enableAccess, getHandlers, isAutoFlush, isEnabled, protect, publish, publish, removeHandler, setAutoFlush, setEnabled, setErrorManager, setFilter, setFormatter, setHandlers, setLevel, unprotect`

### Methods inherited from class java.util.logging.Handler

`getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### PeriodicSizeRotatingFileHandler

    public PeriodicSizeRotatingFileHandler()

Default constructor.

#### PeriodicSizeRotatingFileHandler

    public PeriodicSizeRotatingFileHandler(String fileName)
                                    throws FileNotFoundException

Construct a new instance with the given output file.

Parameters:
  `fileName` - the file name
Throws:
  `FileNotFoundException` - if the file could not be found on open

#### PeriodicSizeRotatingFileHandler

    public PeriodicSizeRotatingFileHandler(String fileName,
                                   boolean append)
                                    throws FileNotFoundException

Construct a new instance with the given output file and append setting.

Parameters:
  `fileName` - the file name
  `append` - `true` to append, `false` to overwrite
Throws:
  `FileNotFoundException` - if the file could not be found on open

#### PeriodicSizeRotatingFileHandler

    public PeriodicSizeRotatingFileHandler(File file,
                                   String suffix)
                                    throws FileNotFoundException

Construct a new instance with the given output file.

Parameters:
  `file` - the file
  `suffix` - the format suffix to use
Throws:
  `FileNotFoundException` - if the file could not be found on open

#### PeriodicSizeRotatingFileHandler

    public PeriodicSizeRotatingFileHandler(File file,
                                   String suffix,
                                   boolean append)
                                    throws FileNotFoundException

Construct a new instance with the given output file and append setting.

Parameters:
  `file` - the file
  `suffix` - the format suffix to use
  `append` - `true` to append, `false` to overwrite
Throws:
  `FileNotFoundException` - if the file could not be found on open

#### PeriodicSizeRotatingFileHandler

    public PeriodicSizeRotatingFileHandler(File file,
                                   String suffix,
                                   long rotateSize,
                                   int maxBackupIndex)
                                    throws FileNotFoundException

Construct a new instance with the given output file.

Parameters:
  `file` - the file
  `suffix` - the format suffix to use
  `rotateSize` - the size the file should rotate at
  `maxBackupIndex` - the maximum number of files to backup
Throws:
  `FileNotFoundException` - if the file could not be found on open

#### PeriodicSizeRotatingFileHandler

    public PeriodicSizeRotatingFileHandler(File file,
                                   String suffix,
                                   long rotateSize,
                                   int maxBackupIndex,
                                   boolean append)
                                    throws FileNotFoundException

Construct a new instance with the given output file.

Parameters:
  `file` - the file
  `suffix` - the format suffix to use
  `rotateSize` - the size the file should rotate at
  `maxBackupIndex` - the maximum number of files to backup
  `append` - `true` to append, `false` to overwrite
Throws:
  `FileNotFoundException` - if the file could not be found on open

### Method Detail

#### setOutputStream

    public void setOutputStream(OutputStream outputStream)

Description copied from class: `OutputStreamHandler`
Set the output stream to write to.

Overrides:
  `setOutputStream` in class `OutputStreamHandler`
Parameters:
  `outputStream` - the new output stream or `null` for none

#### setFile

    public void setFile(File file)
                 throws FileNotFoundException

Description copied from class: `FileHandler`
Set the output file.

Overrides:
  `setFile` in class `PeriodicRotatingFileHandler`
Parameters:
  `file` - the file
Throws:
  `FileNotFoundException` - if an error occurs opening the file

#### isRotateOnBoot

    public boolean isRotateOnBoot()

Indicates whether or a not the handler should rotate the file before the first log record is written.

Returns:
  `true` if file should rotate on boot, otherwise `false`/

#### setRotateOnBoot

    public void setRotateOnBoot(boolean rotateOnBoot)

Set to a value of `true` if the file should be rotated before the a new file is set. The rotation only happens if the file names are the same and the file has a `length` greater than 0.

Parameters:
  `rotateOnBoot` - `true` to rotate on boot, otherwise `false`

#### setRotateSize

    public void setRotateSize(long rotateSize)

Set the rotation size, in bytes.

Parameters:
  `rotateSize` - the number of bytes before the log is rotated

#### setMaxBackupIndex

    public void setMaxBackupIndex(int maxBackupIndex)

Set the maximum backup index (the number of log files to keep around).

Parameters:
  `maxBackupIndex` - the maximum backup index

#### preWrite

    protected void preWrite(ExtLogRecord record)

Description copied from class: `PeriodicRotatingFileHandler`
Execute any pre-write policy, such as file rotation. The write lock is held during this method, so make it quick. The default implementation does nothing. This implementation checks to see if the scheduled rollover time has yet occurred.

Overrides:
  `preWrite` in class `PeriodicRotatingFileHandler`
Parameters:
  `record` - the record about to be logged