JSON Log Formatter

Since version 4.1.1.164

Besides ULF and ODL logging formats available also in GlassFish 4, Payara Server Enterprise provides additional JSON format. With this format, every line in the log output is formatted as a JSON string. The log records can be then easily parsed by a JSON parser for further data processing.

To enable the JSON formatter using the Admin Console, just select JSON from the list of Logging Formats, either for Console or Log File:

JSON format configuration in Web Console

The following administration command will enable the JSON formatter:

asadmin> set-log-attributes com.sun.enterprise.server.logging.GFFileHandler.formatter='fish.payara.enterprise.server.logging.JSONLogFormatter'

Once the JSON formatter is enabled, the log file may look similar to this sample:

Example log file with JSON format

Add an underscore prefix

Since Payara Server 5.182 and 4.1.2.182

The following administration command will add the underscore prefix to field names in JSON Formatter:

asadmin> set-log-attributes fish.payara.deprecated.jsonlogformatter.underscoreprefix=true

By default, fish.payara.deprecated.jsonlogformatter.underscoreprefix property value is false. Once underscore prefix enabled, all JSON fields should be prefixed with underscore, similar to this sample:

Example log file with the underscore prefix in JSON fields