To configure/reconfigure a Logger, use the following console commands and related MBean methods. Since 2.6, Rhino has offered fully asynchronous logging through asynchronous loggers. Asynchronous logging is based on the idea of returning control to the processing thread as early as possible, for maximum throughput.
Rhino allows any individual logger to be asynchronous. This requires careful setup, as the way that log messages are logged is not entirely straightfoward.
In order to get the expected behaviour, that messages to logger foo
are logged asynchronously, and only once, logger foo
must be configured as follows:
-
asynchronous
set to true. Make this logger asynchronous -
additivity
set to false. This prevents double logging of messages if any parent logger also has a reference to the same appenders. -
add relevant appender refs. A non-additive logger must have at least one appender ref to log anything
-
set
level
. Asynchronous loggers do not inherit levels from synchronous parents.
As a result of this complexity, there is no rhino-console command to set or get asynchronous
alone.
Configuring an Asynchronous Logger shows an example.
Possible behaviours with Asynchronous Loggers.
An asynchronous logger may not necessarily behave as expected, with all messages always logged asynchronously. To determine the actual behaviour of an asynchronous logger requires examining the whole path back to the first non-additive parent (or root logger)
Configuration |
Behaviour |
Logger
name : rhino.main level : INFO additivity : false asynchronous: true appenders : [STDERR, RhinoLog, LogNotification, PolledMemoryAppender] Parent
name : root level : INFO additivity : true asynchronous: <not configured - default is false> appenders : [STDERR, RhinoLog, LogNotification, PolledMemoryAppender] |
|
Logger
name : rhino.main level : INFO additivity : false asynchronous: true appenders : [] Parent
name : root level : INFO additivity : true asynchronous: <not configured - default is false> appenders : [STDERR, RhinoLog, LogNotification, PolledMemoryAppender] |
|
Logger
name : rhino.main level : INFO additivity : true asynchronous: true appenders : [] Parent
name : root level : INFO additivity : true asynchronous: <not configured - default is false> appenders : [STDERR, RhinoLog, LogNotification, PolledMemoryAppender] |
|
Logger
name : rhino.main level : INFO additivity : true asynchronous: true appenders : [STDERR, RhinoLog, LogNotification, PolledMemoryAppender] Parent
name : root level : INFO additivity : true asynchronous: <not configured - default is false> appenders : [STDERR, RhinoLog, LogNotification, PolledMemoryAppender] |
|
Logger
name : rhino.main level : INFO additivity : true asynchronous: true appenders : [mainAppender] Parent
name : root level : INFO additivity : true asynchronous: <not configured - default is false> appenders : [STDERR, RhinoLog, LogNotification, PolledMemoryAppender] |
|
Console command: configurelogger
Command |
configurelogger <logKey> [-level <level>] [-additivity <additivity>] [-asynchronous <asynchronosity>] [-appender <appender-ref>]* [-plugin <plugin-name>]* Description Set the configuration for a logger. At least one option must be specified. Plugins can be defined using the defineplugincomponent command. |
---|---|
Example |
$ ./rhino-console configurelogger root -level info -additivity true -appender STDERR -appender RhinoLog -appender LogNotification Created/updated logger configuration for root |
Console command: getloggerconfig
Command |
getloggerconfig <logKey> Description Get the configuration for a logger. Required Arguments logKey The log key of the logger. |
---|---|
Example |
$ ./rhino-console getloggerconfig rhino Logger rhino is not configured $ ./rhino-console getloggerconfig rhino.main name : rhino.main level : INFO additivity : <not configured - default is true> asynchronous: <not configured - default is false> appenders : [] |
Console command: removeloggerconfig
Command |
removeloggerconfig <logKey> Description Remove the configuration for a logger. Required Arguments logKey The log key of the logger. |
---|---|
Example |
$ ./rhino-console removeloggerconfig rhino.main Configuration for logger rhino.main removed |