Configuring binary logging in Liberty

Use this information as a guide for configuring binary logging in your Liberty.

About this task

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. Distributed: [AIX MacOS Linux Windows]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 Editing the Liberty configuration by using developer tools.

The bootstrap.properties file specifies whether the server uses binary logging as the log and trace framework, or the default log and trace framework. A server restart is required to switch between binary logging and the default log and trace framework.

You can modify the configuration of binary logging through the server configuration or the bootstrap.properties file.
  • Server configuration: To get logging from your own code, which is loaded after server configuration processing, use the server configuration to configure binary logging.
  • bootstrap.properties file: You might need to set logging properties to take effect before the server configuration files are processed. For example, if you need to analyze problems that occur early in server start or configuration processing. In this case, you can configure binary logging in the bootstrap.properties file.

You can set Logging properties in either the bootstrap.properties or the server.xml file. Use attributes in the server.xml file, or use equivalent properties in the bootstrap.properties file. Any settings in the bootstrap.properties file are used from the time the server reads the bootstrap.properties file until the time the server.xml file is processed. If the logging properties in the bootstrap.properties file are not replaced or reset in the server.xml file, the property values in the bootstrap.properties file 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, logDirectory, and hideMessage attributes continue to be used to set the trace specification, the level for the console log, the placement of the log and trace files, and the configuration for the messages that you want to hide from the console.log file

If you set logging or binary logging attributes in the server.xml file, you can avoid changes in configuration between startup time and runtime by setting the corresponding properties in the bootstrap.properties file to the same value. If no logging or binary logging properties are set in the bootstrap.properties file, the server uses the default logging settings.

Procedure

  • Enable binary logging for the server by updating the bootstrap.properties file.
    In the bootstrap.properties file, 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 that are listed are subelements of the logging element in the server.xml file.
    The following table lists the attributes that are configurable in the server.xml file and the equivalent properties that can be set in the bootstrap.properties file:
    Table 1. Binary logging attributes that are configurable in server.xml and the equivalent properties that can be set in bootstrap.properties
    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
    The following example shows a bootstrap.properties file that is configured to enable binary logging:
    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 element in Liberty Kernel. For more information about binaryLog and binaryTrace elements, see Binary logging.

Results

After you restart the server, binary logging is enabled and configured.