Skip to content

Commit

Permalink
Merge pull request #47 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 aa2d9b0 + 690f3b0 commit 031a3d7
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 39 deletions.
13 changes: 6 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<artifactId>FHIR_API</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>FHIR_API</name>
<name>FHIR-API</name>
<description>FHIR_NDHM standard integration in AMRIT</description>

<properties>
Expand Down Expand Up @@ -57,12 +57,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>
Expand Down
11 changes: 11 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,14 @@ cron-scheduler-atom-clinical-feed=0 0/1 * * * ? *
patient-search-page-size=5

spring.main.allow-circular-references=true

## logging
logging.level.root=INFO
logging.level.com.iemr.ecd=INFO
logging.level.web=INFO
logging.level.org.springframework.web=INFO
logging.level.org.hibernate=INFO

#If both properties are set, only logging.file.name takes effect.
logging.path=logs/
logging.file.name=logs/fhir-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 031a3d7

Please sign in to comment.