Skip to content

Commit

Permalink
Merge pull request #104 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 930ad24 + 74c7ee8 commit a6869b5
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 42 deletions.
13 changes: 6 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<version>v-1.0</version>
<packaging>war</packaging>

<name>hwc-facility-service</name>
<name>hwc-facility-service-api</name>
<description>Piramal HWC Service / APIs</description>

<parent>
Expand Down Expand Up @@ -48,12 +48,11 @@
<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>
<groupId>org.springframework.boot</groupId>
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,7 @@ logging.level.org.hibernate=INFO
logging.level.com.iemr=DEBUG
logging.level.org.springframework=INFO

# Keep a line at the end so that environment.ts file can be appended properly
logging.path=logs/
logging.file.name=logs/hwc-api.log

# Keep a line at the end so that environment.ts file can be appended properly
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>
34 changes: 0 additions & 34 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 a6869b5

Please sign in to comment.