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]

rhino.main logs asynchronously to STDERR, RhinoLog, LogNotification, and 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]

rhino.main does not log to parent loggers, as it is not additive. rhino.main logs to nowhere as it has no appenders attached to log to.

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]

rhino.main logs nothing directly, and logs synchronously to parent logger. As above, rhino.main has no attached appenders to log to. Calls to the parent logger are always synchronous, regardless of logger asynchrony.

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]

rhino.main logs asynchronously all attached appenders, and synchronously to parent logger. This results in every log message doubling up due to shared appenders.

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]

rhino.main logs asynchronously to mainAppender, and synchronously to parent logger. As no appenders are shared by the loggers, this does not result in messages doubling up. However, calls to rhino.main will synchronously log through appenders attached to root.

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
Make rhino.management log asynchronously to rhino.log only
$ ./rhino-console configurelogger rhino.manangement -level info -additivity false -asynchronous true -appender RhinoLog
Created/updated logger configuration for rhino.management

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
Previous page Next page
Rhino Version 2.6.1