From 7ed6de007543c6fa03ce411f08be130f203e5e70 Mon Sep 17 00:00:00 2001 From: GeorgeC <gcolon021@gmail.com> Date: Thu, 27 Mar 2025 16:03:50 -0400 Subject: [PATCH 1/2] Update logging configuration to support custom patterns and file output Replaced `logback.xml` with `logback-spring.xml` to enable dynamic log configuration using Spring properties. Added support for custom log patterns and log file names across environments. Updated application properties to include logging settings and documented the `log.pattern` property in a new metadata file. --- ...itional-spring-configuration-metadata.json | 8 +++++ .../application-bdc-auth-dev.properties | 5 ++- .../application-bdc-auth-prod.properties | 5 ++- .../resources/application-open.properties | 5 ++- .../src/main/resources/application.properties | 6 ++++ service/src/main/resources/logback-spring.xml | 32 +++++++++++++++++++ service/src/main/resources/logback.xml | 22 ------------- 7 files changed, 58 insertions(+), 25 deletions(-) create mode 100644 service/src/main/resources/META-INF/additional-spring-configuration-metadata.json create mode 100644 service/src/main/resources/logback-spring.xml delete mode 100644 service/src/main/resources/logback.xml diff --git a/service/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/service/src/main/resources/META-INF/additional-spring-configuration-metadata.json new file mode 100644 index 00000000..65869faf --- /dev/null +++ b/service/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -0,0 +1,8 @@ +{ + "properties": [ + { + "name": "log.pattern", + "type": "java.lang.String", + "description": "Description for log.pattern." + } +] } \ No newline at end of file diff --git a/service/src/main/resources/application-bdc-auth-dev.properties b/service/src/main/resources/application-bdc-auth-dev.properties index 81aa5ca3..a60ba1d7 100644 --- a/service/src/main/resources/application-bdc-auth-dev.properties +++ b/service/src/main/resources/application-bdc-auth-dev.properties @@ -9,4 +9,7 @@ data-export.s3.bucket-name=pic-sure-auth-dev-data-export data-export.s3.region=us-east-1 data-export.s3.signedUrl-expiry-minutes=60 -dictionary.host = http://wildfly.___TARGET_STACK___:8080/ \ No newline at end of file +dictionary.host = http://wildfly.___TARGET_STACK___:8080/ + +log.pattern=%d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z', UTC} %-5level --- [auth-hpds] [%thread] %logger{36} : %msg%n +logging.file.name=/var/log/auth-hpds.log \ No newline at end of file diff --git a/service/src/main/resources/application-bdc-auth-prod.properties b/service/src/main/resources/application-bdc-auth-prod.properties index a2269d45..91bb2458 100644 --- a/service/src/main/resources/application-bdc-auth-prod.properties +++ b/service/src/main/resources/application-bdc-auth-prod.properties @@ -9,4 +9,7 @@ data-export.s3.bucket-name=pic-sure-auth-prod-data-export data-export.s3.region=us-east-1 data-export.s3.signedUrl-expiry-minutes=60 -dictionary.host = http://wildfly.___TARGET_STACK___:8080/ \ No newline at end of file +dictionary.host = http://wildfly.___TARGET_STACK___:8080/ + +log.pattern=%d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z', UTC} %-5level --- [auth-hpds] [%thread] %logger{36} : %msg%n +logging.file.name=/var/log/auth-hpds.log \ No newline at end of file diff --git a/service/src/main/resources/application-open.properties b/service/src/main/resources/application-open.properties index d2dc8be4..ca241e28 100644 --- a/service/src/main/resources/application-open.properties +++ b/service/src/main/resources/application-open.properties @@ -1,3 +1,6 @@ SMALL_JOB_LIMIT = 100 SMALL_TASK_THREADS = 1 -LARGE_TASK_THREADS = 1 \ No newline at end of file +LARGE_TASK_THREADS = 1 + +log.pattern=%d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z', UTC} %-5level --- [open-hpds] [%thread] %logger{36} : %msg%n +logging.file.name=/var/log/open-hpds.log \ No newline at end of file diff --git a/service/src/main/resources/application.properties b/service/src/main/resources/application.properties index a4d9352a..e9f8e6cb 100644 --- a/service/src/main/resources/application.properties +++ b/service/src/main/resources/application.properties @@ -1,4 +1,10 @@ SMALL_JOB_LIMIT = 100 SMALL_TASK_THREADS = 1 LARGE_TASK_THREADS = 1 + +# Logging File Output https://docs.spring.io/spring-boot/reference/features/logging.html#features.logging.file-output +# If you are adding additional log files please add them to /var/log/ directory. +logging.file.name=/var/log/hpds.log +logging.level.root=info +log.pattern=%d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z', UTC} %-5level --- [hpds] [%thread] %logger{36} : %msg%n enable_file_sharing=false \ No newline at end of file diff --git a/service/src/main/resources/logback-spring.xml b/service/src/main/resources/logback-spring.xml new file mode 100644 index 00000000..582c4ab2 --- /dev/null +++ b/service/src/main/resources/logback-spring.xml @@ -0,0 +1,32 @@ +<configuration> + <springProperty scope="context" name="LOG_PATTERN" source="log.pattern"/> + <springProperty scope="context" name="LOG_FILE" source="logging.file.name"/> + + <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>${LOG_PATTERN}</pattern> + </encoder> + </appender> + + <appender name="FILE" class="ch.qos.logback.core.FileAppender"> + <file>${LOG_FILE:-var/log/hpds.log}</file> + <encoder> + <pattern>${LOG_PATTERN}</pattern> + </encoder> + </appender> + + <logger name="org.apache.cxf" level="info" additivity="false"> + <appender-ref ref="CONSOLE"/> + <appender-ref ref="FILE"/> + </logger> + + <logger name="org.springframework.boot" level="info" additivity="false"> + <appender-ref ref="CONSOLE"/> + <appender-ref ref="FILE"/> + </logger> + + <root level="debug"> + <appender-ref ref="CONSOLE"/> + <appender-ref ref="FILE"/> + </root> +</configuration> \ No newline at end of file diff --git a/service/src/main/resources/logback.xml b/service/src/main/resources/logback.xml deleted file mode 100644 index c0a7e525..00000000 --- a/service/src/main/resources/logback.xml +++ /dev/null @@ -1,22 +0,0 @@ -<configuration> - - <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> - <layout class="ch.qos.logback.classic.PatternLayout"> - <Pattern> - %d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n - </Pattern> - </layout> - </appender> - - <logger name="org.apache.cxf" level="info" additivity="false"> - <appender-ref ref="CONSOLE"/> - </logger> - <logger name="org.springframework.boot" level="info" additivity="false"> - <appender-ref ref="CONSOLE"/> - </logger> - - <root level="debug"> - <appender-ref ref="CONSOLE"/> - </root> - -</configuration> \ No newline at end of file From 127eefbf2c684da291f5b953d07d8092a29a14d1 Mon Sep 17 00:00:00 2001 From: GeorgeC <gcolon021@gmail.com> Date: Thu, 27 Mar 2025 16:04:29 -0400 Subject: [PATCH 2/2] Remove unused log file configuration properties Deleted `logging.file.name` from application property files as it is no longer required. This simplifies logging configuration and avoids unnecessary file-based logging setup. --- service/src/main/resources/application-bdc-auth-dev.properties | 3 +-- .../src/main/resources/application-bdc-auth-prod.properties | 3 +-- service/src/main/resources/application-open.properties | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/service/src/main/resources/application-bdc-auth-dev.properties b/service/src/main/resources/application-bdc-auth-dev.properties index a60ba1d7..6e884d69 100644 --- a/service/src/main/resources/application-bdc-auth-dev.properties +++ b/service/src/main/resources/application-bdc-auth-dev.properties @@ -11,5 +11,4 @@ data-export.s3.signedUrl-expiry-minutes=60 dictionary.host = http://wildfly.___TARGET_STACK___:8080/ -log.pattern=%d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z', UTC} %-5level --- [auth-hpds] [%thread] %logger{36} : %msg%n -logging.file.name=/var/log/auth-hpds.log \ No newline at end of file +log.pattern=%d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z', UTC} %-5level --- [auth-hpds] [%thread] %logger{36} : %msg%n \ No newline at end of file diff --git a/service/src/main/resources/application-bdc-auth-prod.properties b/service/src/main/resources/application-bdc-auth-prod.properties index 91bb2458..7fa73513 100644 --- a/service/src/main/resources/application-bdc-auth-prod.properties +++ b/service/src/main/resources/application-bdc-auth-prod.properties @@ -11,5 +11,4 @@ data-export.s3.signedUrl-expiry-minutes=60 dictionary.host = http://wildfly.___TARGET_STACK___:8080/ -log.pattern=%d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z', UTC} %-5level --- [auth-hpds] [%thread] %logger{36} : %msg%n -logging.file.name=/var/log/auth-hpds.log \ No newline at end of file +log.pattern=%d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z', UTC} %-5level --- [auth-hpds] [%thread] %logger{36} : %msg%n \ No newline at end of file diff --git a/service/src/main/resources/application-open.properties b/service/src/main/resources/application-open.properties index ca241e28..99a34b59 100644 --- a/service/src/main/resources/application-open.properties +++ b/service/src/main/resources/application-open.properties @@ -2,5 +2,4 @@ SMALL_JOB_LIMIT = 100 SMALL_TASK_THREADS = 1 LARGE_TASK_THREADS = 1 -log.pattern=%d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z', UTC} %-5level --- [open-hpds] [%thread] %logger{36} : %msg%n -logging.file.name=/var/log/open-hpds.log \ No newline at end of file +log.pattern=%d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z', UTC} %-5level --- [open-hpds] [%thread] %logger{36} : %msg%n \ No newline at end of file