diff --git a/Dockerfile b/Dockerfile index f03f213e..33be0d87 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ ####################################################### # Build the spring boot maven project ####################################################### -FROM maven:3.9.3-amazoncorretto-17 as mvn-build-env +FROM maven:3.9.3-amazoncorretto-17 AS mvn-build-env MAINTAINER Thanasis Karampatsis ENV CODE_PATH="/opt/code" @@ -33,6 +33,11 @@ ENV APP_CONFIG_TEMPLATE="/opt/config/application.tmpl" ENV APP_CONFIG_LOCATION="/opt/config/application.yml" ENV SPRING_CONFIG_LOCATION="file:/opt/config/application.yml" +ENV SERVICE="portal-backend" +ENV FEDERATION="default" +ENV LOG_LEVEL="INFO" +ENV FRAMEWORK_LOG_LEVEL="INFO" + WORKDIR /opt RUN apk add --no-cache curl @@ -40,7 +45,7 @@ RUN apk add --no-cache curl ####################################################### # Install dockerize ####################################################### -ENV DOCKERIZE_VERSION v0.6.1 +ENV DOCKERIZE_VERSION=v0.6.1 RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ && tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ && rm dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz diff --git a/config/application.tmpl b/config/application.tmpl index 087ffb0f..08442c58 100644 --- a/config/application.tmpl +++ b/config/application.tmpl @@ -9,16 +9,6 @@ server: forward-headers-strategy: native -### LOG LEVELS ### -logging: - level: - root: {{ default .Env.LOG_LEVEL_FRAMEWORK "ERROR" }} - eu: - hbp: {{ default .Env.LOG_LEVEL "INFO" }} - file: - name: /var/log/portalbackend/portalbackend.log - - ### DATABASE CONFIGURATION ### spring: datasource: diff --git a/pom.xml b/pom.xml index 826a7ca4..bfa59a7f 100644 --- a/pom.xml +++ b/pom.xml @@ -44,6 +44,16 @@ org.springframework.boot spring-boot-starter + + + org.springframework.boot + spring-boot-starter-logging + + + + + org.springframework.boot + spring-boot-starter-log4j2 org.springframework.boot diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 16fb8178..115e0ee8 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -7,15 +7,6 @@ server: port: 8080 forward-headers-strategy: native -### LOG LEVELS ### -logging: - level: - root: "INFO" - eu: - hbp: "DEBUG" - file: - name: /var/log/portalbackend/portalbackend.log - ### DATABASE CONFIGURATION ### spring: datasource: diff --git a/src/main/resources/log4j2.yml b/src/main/resources/log4j2.yml new file mode 100644 index 00000000..8068ef92 --- /dev/null +++ b/src/main/resources/log4j2.yml @@ -0,0 +1,27 @@ +Configuration: + name: Default + + Properties: + Property: + name: log-path + value: "logs" + + Appenders: + Console: + name: ConsoleAppender + target: SYSTEM_OUT + PatternLayout: + pattern: "%d{yyyy-MM-dd HH:mm:ss.SSS} - %-5level - %logger{36} - [${env:FEDERATION:-default}] - [${env:SERVICE:-portal-backend}] - %msg%n" + + Loggers: + logger: + - name: hbp.mip + level: ${env:LOG_LEVEL:-INFO} + additivity: false # Prevent log propagation to parent loggers + AppenderRef: + - ref: ConsoleAppender + + Root: + level: ${env:LOG_LEVEL_FRAMEWORK:-INFO} + AppenderRef: + - ref: ConsoleAppender