Skip to main content
All CollectionsSend your logs
Coralogix log4j integration
Coralogix log4j integration
Eldar Aliiev avatar
Written by Eldar Aliiev
Updated over a year ago

To Download Coralogix SDK

Install:

Coralogix SDK jar is available on Maven Central Repository

Usage:

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

Company ID - A private key which is used to validate your authenticity, this key will be sent to your mail once you register to Coralogix and should not be transferred outside your company.

Private Key - A unique ID which represents your company, this Id will be sent to your mail once you register to Coralogix.

Application Name - The name of your main application, for example, a company named “SuperData” would probably insert the “SuperData” string parameter or if they want to debug their test environment they might insert the “SuperData– Test”.

SubSystem Name - Your application probably has multiple subsystems, for example: Backend servers, Middleware, Frontend servers etc. in order to help you examine the data you need, inserting the subsystem parameter is vital.

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

CORALOGIX_LOG_URL=https://api.Cluster URL/api/v1/logs

Account Url Ending with .us

Account Url Ending with .com

Account Url Ending with .in

api.coralogix.us

api.coralogix.com

api.app.coralogix.in

LOG4J-1 appender:

log4j.appender.CORALOGIX=com.coralogix.sdk.appenders.CoralogixLog4j1Appender log4j.appender.CORALOGIX.companyId=*insert your company ID* log4j.appender.CORALOGIX.privateKey=*Insert your company private key* log4j.appender.CORALOGIX.applicationName=*Insert desired Application name* log4j.appender.CORALOGIX.subsystemName=*Insert desired Subsystem name* log4j.rootLogger=DEBUG, CORALOGIX, YOUR_LOGGER, YOUR_LOGGER2, YOUR_LOGGER3

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

LOG4J-2 APPENDER:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration packages="com.coralogix.sdk.appenders">
<Appenders>
<Coralogix name="Coralogix" companyId="*insert your company ID*" privateKey="*Insert your company private key*" applicationName="*Insert desired Application name*" subSystemName="*Insert desired Subsystem name*">
</Coralogix>
</Appenders>
<Loggers>
<Root level="trace">
<AppenderRef ref="Coralogix"/>
<AppenderRef ref="YOUR_LOGGER"/>
<AppenderRef ref="YOUR_LOGGER2"/>
</Root>
</Loggers>
</Configuration>

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

Did this answer your question?