We believe you should not be limited to application based file shippers.
So to support such cases where you want to integrate your 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.
We support Maven repository.
As we use Artifactory as our repository, you will need to also add a repository to your pom.xml file:
<repositories> <repository> <id>coralogix</id> <name>coralogix repo</name> <url>https://cgx.jfrog.io/artifactory/maven</url> </repository> </repositories>
Then, add the dependency to your pom.xml file:
<dependencies> <dependency> <groupId>com.coralogix.sdk</groupId> <artifactId>coralogix-sdk</artifactId> <version>2.0.10</version> </dependency> </dependencies>
If your Coralogix domain does not end with the suffix .com, input the correct Coralogix API endpoint as follows:
CORALOGIX_LOG_URL=https://<coralogix-api-url>/api/v1/logs
Coralogix Domain | Coralogix API Endpoint |
---|---|
coralogix.com | api.coralogix.com |
coralogix.us | api.coralogix.us |
eu2.coralogix.com | api.eu2.coralogix.com |
coralogix.in | api.app.coralogix.in |
coralogixsg.com | api.coralogixsg.com |
import api.CoralogixLogger; //import the SDK public class logging { public static void main(String[] args) { String privateKey = "*insert your Send-Your-Data API key*"; 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 } }
Please note that line 10 above is required if you would like to use the appender, without this line the Logback appender will not work.
For legacy support, you can still use the old SDK version.
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 } }