This guide explains how to configure Apache Log4j to send logs to Axiom
pom.xml
file. The dependencies required for Log4j include log4j-core
, log4j-api
, and log4j-slf4j2-impl
for logging capability, and jackson-databind
for JSON support.
pom.xml
file and replace its contents with the following:
pom.xml
file includes the necessary Log4j dependencies and configures the Maven Shade plugin to create an executable JAR file.
log4j2.xml
in your root directory and add the following content:
localhost:24224
. Is uses JSON format for the log messages, which makes it easier to parse and analyze the logs later in Axiom.TRACE
: Fine-grained information for debugging.DEBUG
: General debugging information.INFO
: Informational messages.WARN
: Indications of potential problems.ERROR
: Error events that might still allow the app to continue running.FATAL
: Severe error events that might lead the app to cancel.App.java
in the src/main/java/com/example
directory with the following content:
ThreadContext
.
fluentd.conf
in your project root directory with the following content:
API_TOKEN
with the Axiom API token you have generated. For added security, store the API token in an environment variable.Replace DATASET_NAME
with the name of the Axiom dataset where you want to send data.Replace AXIOM_DOMAIN
with api.axiom.co
if your organization uses the US region, and with api.eu.axiom.co
if your organization uses the EU region. For more information, see Regions.java.log4j
tag to all logs.Dockerfile
in your project root directory with the following content: