How to Enable Asynchronous Logging in the Glassfish Enterprise Server
(Doc ID 1125713.1)
Last updated on AUGUST 16, 2018
Applies to:Oracle GlassFish Server - Version 2.1 and later
Information in this document applies to any platform.
The GlassFish Enterprise Server by default uses synchronous logging, where each log record is flushed to the instance's server.log as the log record is generated. With high levels of logging, such as FINE, FINER, FINEST, the overhead involved with synchronous logging becomes more expensive.
With Asynchronous logging, an in-memory log buffer is used to feed log records to the underlying file system logger by a separate logging thread. From a functional point of view, the application server behaves the same as before, however less time is spent performing logging activities.
Asynchronous logging is not enabled by default. This feature is implemented in
- Sun Glassfish Enterprise Server 2.1.1 and later
- Sun Glassfish Enterprise Server 2.1 patch 6
- Sun Glassfish Communication Server 2.0 and later
It can be enabled by
- Setting the JVM option org.glassfish.logging.async to true for the specific configuration you wish to use asynchronous logging for. The existence of this switch is only needed to enable this feature.
- Configure the required asynchronous logging properties in the log-service level of the configuration. Note: any non-numeric value in either property will lead to both properties using their default values, even if one property is a valid numeric value.
- max-buffered-messages (default value : 8192)
This property defines the maximum number of log records that can be buffered before the buffer is flushed. Since log records are buffered before they are flushed, the application server will use more memory using asynchronous logging over the default synchronous logging. Increasing the buffer size excessively could counteract the benefit that changing to asynchronous logging brings.
- push-interval-in-seconds ( default value : 3 minutes)
This property defines how frequently the asynchronous logger will flush pending log records in the buffer.
This document only details the configuration changed needed to enable asynchronous logging for the server.log file. For logging to the access log, the configuration of asynchronous logging is handled differently by setting logging property accessLogWriterInterval (default: off, unit: seconds) and the property accessLogBufferSize (default: 4K, unit: bytes) at the virtual-server property of the respective virtual server. Please refer to the Glassfish Virtual-server documentation for further details. By default, unless the above virtual-server properties are explicitly set, asynchronous logging for access log is not enable and logging to access log is synchronous.
To view full details, sign in with your My Oracle Support account.
Don't have a My Oracle Support account? Click to get started!