Configure binary logging in the Liberty Profile
Use this information as a guide for configuring binary logging in the Liberty profile.
Binary logging provides faster log and trace handling capabilities and more flexible ways to use log and trace content than the default Liberty log and trace framework.
A server configuration consists of a bootstrap.properties file, a server.xml file, and any (optional) files that are included with those files. The bootstrap.properties file specifies properties that need to be available before the main configuration is processed, and are kept to a minimum. The server.xml file is the primary configuration file for the server.
The server.xml file and its associated files use a simple xml format that is suitable for most text editors. A richer editing experience is provided by the eclipse server adapter for Liberty (WAS4D+ adapter), which uses a generated schema to provide drop-down lists of available choices, auto-completion, and other editing tools. For a description of the eclipse server adapter for Liberty, see Edit the Liberty profile configuration using developer tools.
The bootstrap.properties file specifies whether the server should use binary logging as the log and trace framework, or the default log and trace framework.
We can configure binary logging through the server configuration or bootstrap.properties.
- Server configuration: To get logging from our own code, which is loaded after server configuration processing, use the server configuration to configure binary logging.
- bootstrap.properties file: We might need to set logging properties to take effect before the server configuration files are processed. For example, if we need to analyze problems that occur early in server start or configuration processing. In this case, we can configure binary logging in bootstrap.properties.
We can set Logging properties in either the bootstrap.properties or server.xml. Use attributes in server.xml, or use equivalent properties in bootstrap.properties. Any settings in bootstrap.properties are used from the time the server reads the bootstrap.properties file until the time server.xml is processed. If the logging properties in bootstrap.properties are not replaced or reset in server.xml, the property values in bootstrap.properties will continue to be used.
When binary logging is enabled, the maxFileSize, maxFiles, messageFileName, traceFileName, and traceFormat logging element attributes are ignored (since binary logging runs without trace.log and messages.log files). The traceSpecification, consoleLogLevel and logDirectory attributes continue to be used to set the trace specification, the level for the console log, and the placement of the log and trace files.
If you set logging or binary logging attributes in server.xml, we can avoid changes in configuration between startup time and runtime by setting the corresponding properties in the bootstrap.properties file to the same value. Note that if no logging or binary logging properties are set in bootstrap.properties, the server uses the default logging settings.
- Enable binary logging for the server by updating bootstrap.properties. In bootstrap.properties, add the following text on a line by itself:
websphere.log.provider=binaryLogging-1.0
- Use the following parameters to configure binary logging. All subelements listed are subelements of the logging element in server.xml. The following table lists the attributes that are configurable in server.xml and the equivalent properties that can be set in bootstrap.properties:
The following example shows a bootstrap.properties file configured to enable binary logging:
Logging subelement Attribute Equivalent bootstrap.properties property binaryLog purgeMaxSize
purgeMinTime
fileSwitchTime
bufferingEnabled
outOfSpaceAction
com.ibm.hpel.log.purgeMaxSize
com.ibm.hpel.log.purgeMinTime
com.ibm.hpel.log.fileSwitchTime
com.ibm.hpel.log.bufferingEnabled
com.ibm.hpel.log.outOfSpaceAction
binaryTrace purgeMaxSize
purgeMinTime
fileSwitchTime
bufferingEnabled
outOfSpaceAction
com.ibm.hpel.trace.purgeMaxSize
com.ibm.hpel.trace.purgeMinTime
com.ibm.hpel.trace.fileSwitchTime
com.ibm.hpel.trace.bufferingEnabled
com.ibm.hpel.trace.outOfSpaceAction
websphere.log.provider=binaryLogging-1.0
The following example shows a server.xml file with the binary logging subelements. The log content is set to expire after 96 hours and the trace content is set to retain a maximum of 1024MB:
<server description="new server"> <logging> <binaryLog purgeMinTime="96"/> <binaryTrace purgeMaxSize="1024"/> </logging> </server>For the full logging configuration reference, see the logging, binaryLog, and binaryTrace elements in the Configuration elements in server.xml.
Results
After you restart the server, binary logging is enabled and configured.
Parent topic: Binary logging
Parent topic: Administer the Liberty profile manually