To create a file appender, use the following rhino-console command or related MBean operation. Since Rhino 2.6 there are many varieties of file appenders supported.
There are two major classes of file appenders discussed below. Non rolling file appenders do not rollover logfiles ever. Rolling file appenders are able to roll over logfiles, and must be configured with automatic rollover rules.
|
|
FileName arguments are paths to files, not just filenames. To create a logfile in the configured logging directory (Default is ${NODE_HOME}/work/log)
one can use the property ${logDir} as the leading element of the filename
|
Non rolling file appenders
These appenders cannot be rolled over with the rolloverlogfiles console command.
Console command: createfileappender
Command |
createfileappender <appenderName> <fileName> [-append <true|false>] [-bufferedIO
<true|false>] [-bufferSize size] [-createOnDemand <true|false>] [-immediateFlush
<true|false>] [-locking <true|false>] [-ignoreExceptions <true|false>] [-pattern
<pattern>]
Description
The FileAppender is an appender that writes to the File named in the <fileName>
parameter.
Required Arguments
appenderName The name of the Appender.
fileName The name of the file to write to. If the file, or any of its parent
directories, do not exist, they will be created.
Options
-append When true, records will be appended to the end of the file. When set to
false, the file will be cleared before new records are written. The default is
true.
-bufferedIO When true, records will be written to a buffer and the data will be
written to disk when the buffer is full or, if immediateFlush is set, when the
record is written. File locking cannot be used with bufferedIO. The default is
true.
-bufferSize The buffer size. The default is 8192 bytes.
-createOnDemand When true, the appender creates the file on-demand. The default
is false.
-immediateFlush When true, each write will be followed by a flush. This will
guarantee the data is written to disk but could impact performance. The default
is true.
-locking When true, I/O operations will occur only while the file lock is held.
The default is false.
-ignoreExceptions When true, exceptions encountered while appending events will
be internally logged and then ignored. The default is true.
-pattern The pattern to use for logging output.
|
|---|---|
Example |
To create a logfile in the configured logging directory
$ ./rhino-console createfileappender myappender "${logDir}/myappender.log"
Done.
To create a logfile in an absolute path
$ ./rhino-console createfileappender myappender /var/logs/rhino/myappender.log Done. |
Console command: createrandomaccessfileappender
Command |
createrandomaccessfileappender <appenderName> <fileName> [-append <true|false>]
[-immediateFlush <true|false>] [-bufferSize size] [-ignoreExceptions
<true|false>] [-pattern <pattern>]
Description
The RandomAccessFileAppender is an appender that writes to the File named in the
<fileName> parameter. It is similar to the standard FileAppender except it is
always buffered.
Required Arguments
appenderName The name of the Appender.
fileName The name of the file to write to. If the file, or any of its parent
directories, do not exist, they will be created.
Options
-append When true, records will be appended to the end of the file. When set to
false, the file will be cleared before new records are written. The default is
true.
-immediateFlush When true, each write will be followed by a flush. This will
guarantee the data is written to disk but could impact performance. The default
is true.
-bufferSize The buffer size. The default is 8192 bytes.
-ignoreExceptions When true, exceptions encountered while appending events will
be internally logged and then ignored. The default is true.
-pattern The pattern to use for logging output.
|
|---|---|
Example |
$ ./rhino-console createrandomaccessfileappender myappender "${logDir}/myappender.log"
Done.
|
Console command: creatememorymappedfileappender
Command |
creatememorymappedfileappender <appenderName> <fileName> [-append <true|false>]
[-immediateFlush <true|false>] [-regionLength length] [-ignoreExceptions
<true|false>] [-pattern <pattern>]
Description
The MemoryMappedFileAppender maps a part of the specified file into memory and
writes log events to this memory, relying on the operating system's virtual
memory manager to synchronize the changes to the storage device
Required Arguments
appenderName The name of the Appender.
fileName The name of the file to write to. If the file, or any of its parent
directories, do not exist, they will be created.
Options
-append When true, records will be appended to the end of the file. When set to
false, the file will be cleared before new records are written. The default is
true.
-immediateFlush When true, each write will be followed by a flush. This will
guarantee the data is written to disk but could impact performance. The default
is true.
-regionLength The length of the mapped region, defaults to 32 MB.
-ignoreExceptions When true, exceptions encountered while appending events will
be internally logged and then ignored. The default is true.
-pattern The pattern to use for logging output.
|
|---|---|
Example |
$ ./rhino-console creatememorymappedfileappender myappender "${logDir}/myappender.log"
Done.
|
Rolling file appenders
Console command: createrollingfileappender
Command |
createrollingfileappender <appenderName> <fileName> <filePattern> <size>
[-append <true|false>] [-bufferedIO <true|false>] [-bufferSize size]
[-createOnDemand <true|false>] [-immediateFlush <true|false>] [-min <min>] [-max
<max>] [-ignoreExceptions <true|false>] [-pattern <pattern>]
Description
The RollingFileAppender is an appender that writes to the File named in the
<fileName> parameter and rolls the file over according the values set by the
<size> [-min][-max] options.
Required Arguments
appenderName The name of the Appender.
fileName The name of the file to write to. If the file, or any of its parent
directories, do not exist, they will be created.
filePattern The pattern of the file name of the archived log file. Both a
date/time pattern compatible with SimpleDateFormat and/or a %i which represents
an integer counter can be used.
size The file size required before a roll over will occur.
Options
-append When true, records will be appended to the end of the file. When set to
false, the file will be cleared before new records are written. The default is
true.
-bufferedIO When true, records will be written to a buffer and the data will be
written to disk when the buffer is full or, if immediateFlush is set, when the
record is written. File locking cannot be used with bufferedIO. The default is
true.
-bufferSize The buffer size. The default is 8192 bytes.
-createOnDemand When true, the appender creates the file on-demand. The default
is false.
-immediateFlush When true, each write will be followed by a flush. This will
guarantee the data is written to disk but could impact performance. The default
is true.
-min The minimum value of the roll over counter. The default value is 1.
-max The maximum value of the roll over counter. Once this values is reached
older archives will be deleted on subsequent rollovers.
-ignoreExceptions When true, exceptions encountered while appending events will
be internally logged and then ignored. The default is true.
-pattern The pattern to use for logging output.
|
|---|---|
Example |
$ ./rhino-console createrollingfileappender myappender "${logDir}/myappender.log"
Done.
|
Console command: createrollingrandomaccessfileappender
Command |
createrollingrandomaccessfileappender <appenderName> <fileName> <filePattern>
<size> [-append <true|false>] [-bufferSize size] [-immediateFlush <true|false>]
[-min <min>] [-max <max>] [-ignoreExceptions <true|false>] [-pattern <pattern>]
Description
The RollingRandomAccessFileAppender is an appender that writes to the File named
in the <fileName> parameter and rolls the file over according the values set by
the <size>[-min][-max] options. It is similar to the standard
RollingFileAppender except it is always buffered.
Required Arguments
appenderName The name of the Appender.
fileName The name of the file to write to. If the file, or any of its parent
directories, do not exist, they will be created.
filePattern The pattern of the file name of the archived log file. Both a
date/time pattern compatible with SimpleDateFormat and/or a %i which represents
an integer counter can be used.
size The file size required before a roll over will occur.
Options
-append When true, records will be appended to the end of the file. When set to
false, the file will be cleared before new records are written. The default is
true.
-bufferSize The buffer size. The default is 8192 bytes.
-immediateFlush When true, each write will be followed by a flush. This will
guarantee the data is written to disk but could impact performance. The default
is true.
-min The minimum value of the roll over counter. The default value is 1.
-max The maximum value of the roll over counter. Once this values is reached
older archives will be deleted on subsequent rollovers.
-ignoreExceptions When true, exceptions encountered while appending events will
be internally logged and then ignored. The default is true.
-pattern The pattern to use for logging output.
|
|---|---|
Example |
$ ./rhino-console createrollingrandomaccessfileappender myappender "${logDir}/myappender.log"
Done.
|
