Follow this guide to integrate Logpulse with your application and start visualizing your logs in real-time.
Add the following dependency to your pom.xml:
<dependency>
<groupId>io.github.koushikruidas</groupId>
<artifactId>log-analyzer-client</artifactId>
<version>1.0.0</version>
</dependency>
Add the following to your build.gradle:
dependencies {
implementation 'io.github.koushikruidas:log-analyzer-client:1.0.0'
}
Having trouble with the integration? Our support team is here to help! Contact us at support@logpulse.io
Create or update log4j2.xml in src/main/resources with properties for Kafka, TLS and the Logpulse admin URL. Example:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="info" name="spring-boot-kafka-log">
<Properties>
<Property name="bootstrap.servers">${env:KAFKA_SERVERS}</Property>
<Property name="apiKey">${env:LOG_ANALYZER_TOKEN}</Property>
</Properties>
<Appenders>
<Kafka name="Kafka" topic="${kafka.topic}">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"/>
</Kafka>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="Kafka"/>
</Root>
</Loggers>
</Configuration>
In your main application class, add @ComponentScan:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
@ComponentScan(basePackages = {"com.poinciana.loganalyzerClient"})
public class GenerateLogsApplication {
public static void main(String[] args) {
SpringApplication.run(GenerateLogsApplication.class, args);
}
}
Build and run your application as usual. Your logs will be sent to logpulse.io via the configured Kafka appender.