Skip to content

Logback

The following tutorial demonstrates how to integrate Logback with Coralogix Java SDK.

Requirements:

You need to have the Coralogix Java SDK integrated into your project.
Read all about it, Here.

Usage:

You must provide the following four variables when creating a Coralogix logger instance.

ParameterDescription
Private KeyCoralogix Send-Your-Data API key
*Company ID*A unique ID that represents your company.
The ID can be found under ‘settings’->’ send your logs’.
Application NameThe application Tag you wish to append to every log line sent
SubSystem NameThe subsystem Tag you wish to append to every log line sent

If your Coralogix account top-level domain is not ‘.com’ set the following environment variables:

CORALOGIX_LOG_URL=https://<coralogix_cluster_url>/api/v1/logs
Cluster locationcoralogix_cluster_url
USapi.coralogix.us
Indiaapi.app.coralogix.in
Singaporeapi.coralogixsg.com

Below are Code examples to demonstrate how to add the appender

Logback appender:

<?xml version=”1.0″ encoding=”UTF-8″?>
<configuration debug=”true”>
<appender name=”coralogix” class=”com.coralogix.sdk.appenders.CoralogixLogbackAppender”>
<companyId>*insert your company ID*</companyId>
<privateKey>*Insert your Send-Your-Data API key key*</privateKey>
<applicationName>*Insert desired Application name*</applicationName>
<subsystemName>*Insert desired Subsystem name*</subsystemName>
<mdc>firstKeyName,secondKeyName,thirdKeyName</mdc> *optional field*
</appender>
<root level=”debug”>
<appender-ref ref=”coralogix”/>
<appender-ref ref=”YOUR_LOGGER”/>
<appender-ref ref=”YOUR_LOGGER2″/>
</root>
</configuration>

Note!: YOUR_LOGGER is another logger you have defined in your log4j configuration that you want to be defined on the rootLogger

Need help? We love to assist our customers, simply reach out via our in-app chat, and we will walk you through, step by step.