Skip to content

Commit 0fd956e

Browse files
authored
Merge pull request #75 from ivor11/feat/elk-stack-setup
feat(elk-stack-setup): add ecs logging for elastic setup
2 parents 0a137a8 + 72304c7 commit 0fd956e

File tree

5 files changed

+44
-41
lines changed

5 files changed

+44
-41
lines changed

pom.xml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
<packaging>war</packaging>
1111

12-
<name>identity</name>
12+
<name>identity-api</name>
1313
<description>iEMR Identity Service</description>
1414

1515
<parent>
@@ -60,19 +60,16 @@
6060
<dependency>
6161
<groupId>org.springframework.boot</groupId>
6262
<artifactId>spring-boot-starter</artifactId>
63-
64-
<exclusions>
65-
<exclusion>
66-
<groupId>org.springframework.boot</groupId>
67-
<artifactId>spring-boot-starter-logging</artifactId>
68-
</exclusion>
69-
</exclusions>
7063
</dependency>
7164
<dependency>
7265
<groupId>org.springframework.boot</groupId>
7366
<artifactId>spring-boot-starter-web</artifactId>
7467
</dependency>
75-
68+
<dependency>
69+
<groupId>co.elastic.logging</groupId>
70+
<artifactId>logback-ecs-encoder</artifactId>
71+
<version>1.3.2</version>
72+
</dependency>
7673
<dependency>
7774
<groupId>org.springframework.boot</groupId>
7875
<artifactId>spring-boot-devtools</artifactId>

src/main/resources/application.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ logging.level.org.hibernate=INFO
2828
logging.level.com.iemr=DEBUG
2929
logging.level.org.springframework=INFO
3030

31+
logging.path=logs/
32+
logging.file.name=logs/identity-api.log
33+
3134
spring.datasource.tomcat.initial-size=5
3235
spring.datasource.tomcat.max-idle=15
3336
spring.datasource.tomcat.max-active=30

src/main/resources/logback-spring.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<configuration>
2+
<property name="LOG_FILE"
3+
value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}}/my-api}" />
4+
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
5+
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />
6+
<appender name="ECS_JSON_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
7+
<file>${LOG_FILE}.json</file>
8+
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
9+
<fileNamePattern>${LOG_FILE}.json.%d{yyyy-MM-dd}.gz</fileNamePattern>
10+
<maxFileSize>100MB</maxFileSize>
11+
<maxHistory>0</maxHistory>
12+
<cleanHistoryOnStart>true</cleanHistoryOnStart>
13+
</rollingPolicy>
14+
<encoder class="co.elastic.logging.logback.EcsEncoder" />
15+
</appender>
16+
<appender name="ASYNC_ECS" class="ch.qos.logback.classic.AsyncAppender">
17+
<appender-ref ref="ECS_JSON_FILE" />
18+
<queueSize>512</queueSize>
19+
<discardingThreshold>0</discardingThreshold>
20+
<includeCallerData>false</includeCallerData>
21+
</appender>
22+
23+
<root level="INFO">
24+
<appender-ref ref="CONSOLE" />
25+
<appender-ref ref="ASYNC_ECS" />
26+
</root>
27+
</configuration>

src/main/resources/logback.xml

Lines changed: 0 additions & 32 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<jboss-deployment-structure>
2+
<deployment>
3+
<exclusions>
4+
<module name="org.slf4j" />
5+
<module name="org.slf4j.impl" />
6+
</exclusions>
7+
</deployment>
8+
</jboss-deployment-structure>

0 commit comments

Comments
 (0)