Skip to content

Commit

Permalink
fix: create logback configuration files for each environment
Browse files Browse the repository at this point in the history
  • Loading branch information
neumanf committed Jan 1, 2025
1 parent bc24ef8 commit d844eb4
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Run backend
uses: JarvusInnovations/background-action@v1
with:
run: docker compose -f docker-compose.testing.yml up &
run: docker compose -f docker-compose.test.yml up &
wait-on: http://localhost:8080/health/
wait-for: 10m

Expand Down
3 changes: 3 additions & 0 deletions apps/api/src/main/resources/application.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ spring:
jwt:
issuer-uri: ${KEYCLOAK_ISSUER_URL}

logging:
config: classpath:logback-prod.xml

management:
endpoints:
web:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ spring:
jwt:
issuer-uri: "http://keycloak:9090/realms/mally"

logging:
config: classpath:logback-test.xml

bucket4j:
enabled: true
filter-config-caching-enabled: true
Expand Down
3 changes: 3 additions & 0 deletions apps/api/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ spring:
jwt:
issuer-uri: "http://localhost:9090/realms/mally"

logging:
config: classpath:logback-test.xml

bucket4j:
enabled: true
filter-config-caching-enabled: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />

Expand Down
18 changes: 18 additions & 0 deletions apps/api/src/main/resources/logback-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />

<property name="CONSOLE_LOG_PATTERN" value="%highlight([%level]) %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %X{id} %c{1} - %msg%n" />

<appender name="CONSOLE_APPENDER" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
<charset>utf8</charset>
</encoder>
</appender>

<root level="INFO">
<appender-ref ref="CONSOLE_APPENDER" />
</root>
</configuration>
2 changes: 1 addition & 1 deletion apps/api/testing.Dockerfile → apps/api/test.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ FROM eclipse-temurin:21-jre-alpine

ENV ARTIFACT_NAME=api-0.0.1-SNAPSHOT.jar
ENV APP_HOME=/app
ENV CONFIGURATION_FILE=application.testing.yml
ENV CONFIGURATION_FILE=application.test.yml

RUN apk add curl

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.testing.yml → docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ services:
container_name: mally-api
build:
context: .
dockerfile: ./apps/api/testing.Dockerfile
dockerfile: ./apps/api/test.Dockerfile
restart: unless-stopped
networks:
- mally-network
Expand Down

0 comments on commit d844eb4

Please sign in to comment.