FINERACT-1724: JSON logging support

This commit is contained in:
Arnold Galovics
2023-03-27 16:03:39 +02:00
committed by Adam Saghy
parent 24bc7bb5fb
commit eb91d44c90
5 changed files with 41 additions and 11 deletions
@@ -44,6 +44,10 @@ dependencyManagement {
dependency 'org.slf4j:log4j-over-slf4j:1.7.36'
dependency 'ch.qos.logback:logback-core:1.2.11'
dependency 'ch.qos.logback:logback-classic:1.2.11'
dependency 'ch.qos.logback.contrib:logback-json-classic:0.1.5'
dependency 'ch.qos.logback.contrib:logback-jackson:0.1.5'
dependency 'org.codehaus.janino:janino:3.1.9'
dependency 'org.eclipse.persistence:org.eclipse.persistence.jpa:2.7.10'
dependency 'com.google.guava:guava:31.1-jre'
+4
View File
@@ -164,6 +164,10 @@ dependencies {
annotationProcessor 'org.projectlombok:lombok'
annotationProcessor 'org.mapstruct:mapstruct-processor'
implementation 'ch.qos.logback.contrib:logback-json-classic'
implementation 'ch.qos.logback.contrib:logback-jackson'
implementation 'org.codehaus.janino:janino'
// testCompile dependencies are ONLY used in src/test, not src/main.
// Do NOT repeat dependencies which are ALREADY in implementation or runtimeOnly!
//
@@ -104,6 +104,7 @@ fineract.report.export.s3.enabled=${FINERACT_REPORT_EXPORT_S3_ENABLED:false}
fineract.jpa.statementLoggingEnabled=${FINERACT_STATEMENT_LOGGING_ENABLED:false}
fineract.notification.user-notification-system.enabled=${FINERACT_USER_NOTIFICATION_SYSTEM_ENABLED:true}
fineract.logging.json.enabled=${FINERACT_LOGGING_JSON_ENABLED:false}
# Logging pattern for the console
logging.pattern.console=${CONSOLE_LOG_PATTERN:%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(%replace([%X{correlationId}]){'\\[\\]', ''}) %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:%wEx}}
@@ -20,9 +20,11 @@
-->
<configuration>
<springProperty name="jsonLoggingEnabled" source="fineract.logging.json.enabled" defaultValue="false"/>
<!-- see https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-custom-log-configuration
and https://github.com/spring-projects/spring-boot/tree/master/spring-boot-project/spring-boot/src/main/resources/org/springframework/boot/logging/logback -->
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<appender name="CONSOLE" target="System.out" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
@@ -30,15 +32,33 @@
</encoder>
</appender>
<!-- See https://github.com/apache/fineract/#logging-guidelines for why by default we log only to INFO, only (WARN and) ERROR
but it's still possible to override this using java -Dlogging.level.root=info -jar fineract-provider.jar, as per https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-custom-log-levels -->
<root level="info">
<appender-ref ref="CONSOLE" />
</root>
<!-- But these three INFO are still handy ;-) just to see when it's up and running -->
<logger name="org.springframework.boot.web.embedded.tomcat.TomcatWebServer" level="info" />
<logger name="org.apache.fineract.ServerApplication" level="info" />
<logger name="org.apache.fineract" level="${FINERACT_LOGGING_LEVEL:-INFO}" />
<logger name="liquibase" level="info" />
<logger name="org.springframework.boot.web.embedded.tomcat.TomcatWebServer" level="info"/>
<logger name="org.apache.fineract.ServerApplication" level="info"/>
<logger name="org.apache.fineract" level="${FINERACT_LOGGING_LEVEL:-INFO}"/>
<logger name="liquibase" level="info"/>
<if condition="${jsonLoggingEnabled} == true">
<then>
<appender name="JSON" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.contrib.json.classic.JsonLayout">
<jsonFormatter class="ch.qos.logback.contrib.jackson.JacksonJsonFormatter">
<prettyPrint>false</prettyPrint>
</jsonFormatter>
<appendLineSeparator>true</appendLineSeparator>
</layout>
</appender>
<root level="info">
<appender-ref ref="JSON"/>
</root>
</then>
<else>
<!-- See https://github.com/apache/fineract/#logging-guidelines for why by default we log only to INFO, only (WARN and) ERROR
but it's still possible to override this using java -Dlogging.level.root=info -jar fineract-provider.jar, as per https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-custom-log-levels -->
<root level="info">
<appender-ref ref="CONSOLE"/>
</root>
</else>
</if>
</configuration>
@@ -112,6 +112,7 @@ public class ClasspathDuplicatesStepDefinitions implements En {
|| resourcePath.equals("META-INF/ECLIPSE_.RSA") || resourcePath.equals("META-INF/BC2048KE.DSA")
|| resourcePath.equals("META-INF/BC1024KE.DSA") || resourcePath.equals("META-INF/BC2048KE.SF")
|| resourcePath.equals("META-INF/BC1024KE.SF") || resourcePath.equals("OSGI-INF/bundle.info")
|| resourcePath.equals("META-INF/DUMMY.SF") || resourcePath.equals("META-INF/DUMMY.DSA")
// Spring Framework knows what they are do..
|| resourcePath.startsWith("META-INF/spring") || resourcePath.startsWith("META-INF/additional-spring")
|| resourcePath.startsWith("META-INF/terracotta")