Skip to content

Commit

Permalink
Merge pull request #21 from ivor11/feat/elk-stack-setup
Browse files Browse the repository at this point in the history
feat(elk-stack-setup): add ecs logging for elastic setup
  • Loading branch information
drtechie authored Nov 14, 2024
2 parents 66dc99d + a4f459f commit 67a836a
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 38 deletions.
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>co.elastic.logging</groupId>
<artifactId>logback-ecs-encoder</artifactId>
<version>1.3.2</version>
</dependency>

<dependency>
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,6 @@ logging.level.org.springframework.web=INFO
logging.level.org.hibernate=INFO
logging.level.com.iemr=DEBUG
logging.level.org.springframework=INFO

logging.path=logs/
logging.file.name=logs/helpline1097-api.log
27 changes: 27 additions & 0 deletions src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<configuration>
<property name="LOG_FILE"
value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}}/my-api}" />
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />
<appender name="ECS_JSON_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_FILE}.json</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${LOG_FILE}.json.%d{yyyy-MM-dd}.gz</fileNamePattern>
<maxFileSize>100MB</maxFileSize>
<maxHistory>0</maxHistory>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder class="co.elastic.logging.logback.EcsEncoder" />
</appender>
<appender name="ASYNC_ECS" class="ch.qos.logback.classic.AsyncAppender">
<appender-ref ref="ECS_JSON_FILE" />
<queueSize>512</queueSize>
<discardingThreshold>0</discardingThreshold>
<includeCallerData>false</includeCallerData>
</appender>

<root level="INFO">
<appender-ref ref="CONSOLE" />
<appender-ref ref="ASYNC_ECS" />
</root>
</configuration>
32 changes: 0 additions & 32 deletions src/main/resources/logback.xml

This file was deleted.

8 changes: 8 additions & 0 deletions src/main/webapp/WEB-INF/jboss-deployment-structure.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.slf4j" />
<module name="org.slf4j.impl" />
</exclusions>
</deployment>
</jboss-deployment-structure>

0 comments on commit 67a836a

Please sign in to comment.