Link Search Menu Expand Document Documentation Menu

Configuring Log4j

You can configure logging using Log4j in OpenSearch Data Prepper.

Logging

Data Prepper uses SLF4J with a Log4j 2 binding.

Data Prepper reads its Log4j 2 configuration from the config/log4j2-rolling.properties file in the Data Prepper home directory. To customize logging, edit or replace this file. In Docker, the file path is /usr/share/data-prepper/config/log4j2-rolling.properties.

To use a configuration file in a different location, set the log4j.configurationFile system property in the JAVA_OPTS environment variable before starting Data Prepper:

export JAVA_OPTS="-Dlog4j.configurationFile=/path/to/log4j2.properties"
bin/data-prepper

In Docker, pass the environment variable using the -e option and mount the configuration file into the container:

docker run --name data-prepper \
  -e JAVA_OPTS="-Dlog4j.configurationFile=/usr/share/data-prepper/custom/log4j2.properties" \
  -v ${PWD}/log4j2.properties:/usr/share/data-prepper/custom/log4j2.properties \
  -v ${PWD}/pipelines.yaml:/usr/share/data-prepper/pipelines/pipelines.yaml \
  opensearchproject/data-prepper:latest

See the Log4j 2 configuration documentation for more information about Log4j 2 configuration.

350 characters left

Have a question? .

Want to contribute? or .