We're launching a new cybersecurity venture! Learn more about Snowbit >

Java Java

Last Updated: Mar. 30, 2022

We believe you should no be limited to application based file shippers.

So to support such cases where you want to integrate you application to Coralogix on the basic code level we provide easy to use SDKs.

Our SDKs will integrate with the basic logger functions and will also offer appenders support for Java.

How to use the SDK:

You will need to add the Coralogix SDK to you projects build dependencies.
We support Maven repository.
And you can download our SDK from here

You are welcome to review our Java Sample Project repository

Requirements:

ParameterDescription
Private KeyThe private key can be found under ‘settings’->’ send your logs’.
Company IDA unique ID that represents your company.
The private key 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 Account is not in the EU region (the account url does not have a .com suffix)

you will need to add this environment variable:

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

Code Example (for SDK versions 2.x):

import api.CoralogixLogger; //import the SDK

public class logging {

    public static void main(String[] args) {
        String privateKey = "*insert the private key you received after signup*";
        String appName = "*Insert desired Application name*";
        String subSystem = "*Insert desired subsystem name*";

        CoralogixLogger.configure(privateKey, appName, subSystem); //Create a connection object to Coralogix
        CoralogixLogger logger = new CoralogixLogger(logging.class.toString()); //Create a generic logger object which the Coralogix SDK

        logger.info("my info log"); //Test the log shipping
    }
}

Code Example (for SDK versions 1.x):

import com.coralogix.sdk.api.CoralogixLogger; //import the SDK
import com.coralogix.sdk.api.CoralogixSDK; //import the SDK

public class logging {
    public static void main(String[] args) throws Exception{

        String privateKey = "*insert the private key you received after signup*";
        int companyId = "*insert the company ID you received after signup*";
        String appName = *companyId* + "*Insert desired Application name*";
        String subsystem = "*Insert desired subsystem name*";

        CoralogixLogger logger = CoralogixSDK.createAndConnectNewLogger(appName, subsystem, companyId, privateKey); //Create a connection object to Coralogix
        logger.sendCriticalLog("This is my serious test log 1"); //Test the log shipping
    }
}

On this page