Skip to content

Commit

Permalink
CIRC-1645 Update logging configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
OleksandrVidinieiev committed Jan 17, 2023
1 parent c571e20 commit 8aa1937
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 1 deletion.
1 change: 1 addition & 0 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<!-- OPTIONAL
- [ ] Use GitHub checklists. When solved, check the box and explain the answer.
-->
- [ ] Check logging

## Learning
<!-- OPTIONAL
Expand Down
39 changes: 39 additions & 0 deletions src/main/resources/log4j2-json.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
status = error
name = PropertiesConfig
packages = org.folio.okapi.common.logging

filters = threshold

filter.threshold.type = ThresholdFilter
filter.threshold.level = info

appenders = console

appender.console.type = Console
appender.console.name = STDOUT
appender.console.layout.type = JSONLayout
appender.console.layout.compact = true
appender.console.layout.eventEol = true
appender.console.layout.stacktraceAsString = true
appender.console.layout.includeTimeMillis = true

## Folio fields
appender.console.layout.requestId.type = KeyValuePair
appender.console.layout.requestId.key = requestId
appender.console.layout.requestId.value = $${FolioLoggingContext:requestid}

appender.console.layout.tenantId.type = KeyValuePair
appender.console.layout.tenantId.key = tenantId
appender.console.layout.tenantId.value = $${FolioLoggingContext:tenantid}

appender.console.layout.userId.type = KeyValuePair
appender.console.layout.userId.key = userId
appender.console.layout.userId.value = $${FolioLoggingContext:userid}

appender.console.layout.moduleId.type = KeyValuePair
appender.console.layout.moduleId.key = moduleId
appender.console.layout.moduleId.value = $${FolioLoggingContext:moduleid}

rootLogger.level = info
rootLogger.appenderRefs = info
rootLogger.appenderRef.stdout.ref = STDOUT
3 changes: 2 additions & 1 deletion src/main/resources/log4j2.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
status = error
name = PropertiesConfig
packages = org.folio.okapi.common.logging

filters = threshold

Expand All @@ -11,7 +12,7 @@ appenders = console
appender.console.type = Console
appender.console.name = STDOUT
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = %d{HH:mm:ss} %-5p %-20.20C{1} %m%n
appender.console.layout.pattern = %d{HH:mm:ss} [$${FolioLoggingContext:requestid}] [$${FolioLoggingContext:tenantid}] [$${FolioLoggingContext:userid}] [$${FolioLoggingContext:moduleid}] %-5p %-20.20C{1} %.-10240m%n

rootLogger.level = info
rootLogger.appenderRefs = info
Expand Down
19 changes: 19 additions & 0 deletions src/test/resources/log4j2-test.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
status = error
name = PropertiesConfig
packages = org.folio.okapi.common.logging

filters = threshold

filter.threshold.type = ThresholdFilter
filter.threshold.level = info

appenders = console

appender.console.type = Console
appender.console.name = STDOUT
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = %d{HH:mm:ss} [$${FolioLoggingContext:requestid}] [$${FolioLoggingContext:tenantid}] [$${FolioLoggingContext:userid}] [$${FolioLoggingContext:moduleid}] %-5p %-20.20C{1} %.-10240m%n

rootLogger.level = info
rootLogger.appenderRefs = info
rootLogger.appenderRef.stdout.ref = STDOUT

0 comments on commit 8aa1937

Please sign in to comment.