log-format

The log-format global parameter sets the format of log output to the console or to log files. Liquibase Open Source users default to unstructured TEXT logs to the console or output log files. Liquibase Pro users have the option to set the value as JSON or JSON_PRETTY to enable JSON-structured log files to the console or output log files. The default value is TEXT.

Uses

By default, Liquibase creates unstructured text strings when it generates command output. This information is helpful, but complicated to parse with a script. If you use Liquibase Pro, you can enable Structured Logging by setting log-format to JSON or JSON_PRETTY. Liquibase Structured Logs are formatted as a group of key-value pairs in JSON (JavaScript Object Notation). This allows you to integrate Liquibase with external log analysis tools like AWS Cloudwatch, ElasticSearch, and others.

If you set log-format to JSON, the output is generated in a machine-readable format with minimal whitespace. If you set it to JSON_PRETTY, the output is still machine-readable but also includes whitespace and indentation to be human-readable. You can also set log-format to TEXT or leave it blank to use unstructured logs.

By default, the output of log-format is sent to STDOUT. You can also send it to a file you specify with the log-file parameter.

Syntax

You can set this parameter in the following ways:

Option Syntax
Liquibase properties file
liquibase.logFormat: <string>
Global flow file argument (example)
stages:
  Default:
    actions:
      - type: liquibase
        command: update
        globalArgs: { log-format: "<string>" }
Global CLI parameter
liquibase
 --log-format=<string> update
 --changelog-file=example-changelog.xml

JVM system property (JAVA_OPTS Environment Variable)

JAVA_OPTS=-Dliquibase.logFormat=<string>
Liquibase Environment Variables
LIQUIBASE_LOG_FORMAT=<string>

For more information, see Working with Command Parameters.

Output

log-format=TEXT

[2023-03-15 14:57:40] INFO [liquibase.integration] Starting command execution.
Running Changeset: example-changelog.sql::2::anotherdev
[2023-03-15 14:57:40] INFO [liquibase.changelog] Custom SQL executed
[2023-03-15 14:57:40] INFO [liquibase.changelog] ChangeSet example-changelog.sql::2::anotherdev ran successfully in 5ms
[2023-03-15 14:57:40] INFO [liquibase.executor] Changelog query completed.
[2023-03-15 14:57:40] INFO [liquibase.lockservice] Successfully released change log lock

log-format=JSON

Structured Logs:
{"timestamp":"2023-03-15T19:56:34.241Z","level":"INFO","class":"liquibase.changelog","thread":"1","message":"ChangeSet cafe-changelog.sql::2::DavtheDev ran successfully in 5ms","liquibaseOperation":"update","liquibaseCommandName":"update","liquibaseTargetUrl":"jdbc:h2:tcp://localhost:9090/mem:dev","commandLabelFilter":"","commandContextFilter":"","deploymentId":"8910194201","changesetId":"2","changesetAuthor":"DavtheDev","changesetFilepath":"cafe-changelog.sql","changesetComment":"set up the company table","changesetLabel":"setup","changesetContext":"dev,prod","changesetOperationStart":"2023-03-15T14:56:34.236","changesetSql":"create table company (\n    id int primary key auto_increment not null,\n    name varchar(50) not null,\n    address1 varchar(50),\n    address2 varchar(50),\n    city varchar(30)\n);","changesetOperationStop":"2023-03-15T14:56:34.24","changesetOutcome":"executed"}

log-format=JSON_PRETTY

Structured Logs:
{
  "timestamp": "2023-03-15T19:56:34.241Z",
  "level": "INFO",
  "class": "liquibase.changelog",
  "thread": "1",
  "message": "ChangeSet cafe-changelog.sql::2::DavtheDev ran successfully in 5ms",
  "liquibaseOperation": "update",
  "liquibaseCommandName": "update",
  "liquibaseTargetUrl": "jdbc:h2:tcp://localhost:9090/mem:dev",
  "commandLabelFilter": "",
  "commandContextFilter": "",
  "deploymentId": "8910194201",
  "changesetId": "2",
  "changesetAuthor": "DavtheDev",
  "changesetFilepath": "cafe-changelog.sql",
  "changesetComment": "set up the company table",
  "changesetLabel": "setup",
  "changesetContext": "dev,prod",
  "changesetOperationStart": "2023-03-15T14:56:34.236",
  "changesetSql": "create table company (\n    id int primary key auto_increment not null,\n    name varchar(50) not null,\n    address1 varchar(50),\n    address2 varchar(50),\n    city varchar(30)\n);",
  "changesetOperationStop": "2023-03-15T14:56:34.24",
  "changesetOutcome": "executed"
}

Related links