OBPIH-6858 enable color logs for dev and testing only#4959
OBPIH-6858 enable color logs for dev and testing only#4959awalkowiak merged 2 commits intodevelopfrom
Conversation
| # we don't want to break any log processors in production. https://logback.qos.ch/manual/layouts.html | ||
| logging: | ||
| pattern: | ||
| console: "%cyan(%date{ISO8601}) %highlight(%-5level) %magenta([%thread]) %yellow(%logger{40}): %message%n%xException" |
There was a problem hiding this comment.
I originally tried doing this via Grails' environment properties:
environments:
development:
logging:
pattern:
console: <pattern with colors>
...
logging:
pattern:
console: <pattern without colors>
but unfortunately the environment specific property didn't get picked up by Logback. I assume it's because the environments is a Grails thing that doesn't get properly passed down to Logback.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #4959 +/- ##
============================================
- Coverage 7.62% 7.62% -0.01%
+ Complexity 818 816 -2
============================================
Files 600 600
Lines 42275 42275
Branches 10276 10276
============================================
- Hits 3224 3222 -2
Misses 38586 38586
- Partials 465 467 +2 ☔ View full report in Codecov by Sentry. |
| <configuration> | ||
|
|
||
| <include resource="org/springframework/boot/logging/logback/defaults.xml"/> | ||
| <include resource="org/springframework/boot/logging/logback/console-appender.xml"/> |
There was a problem hiding this comment.
This is what gets imported here: https://github.com/spring-projects/spring-boot/blob/main/spring-boot-project/spring-boot/src/main/resources/org/springframework/boot/logging/logback/console-appender.xml
It saves us from having to define our own console appender since we're just using the default config anyways. Then we can override the format with the logging.pattern.console: property which maps to CONSOLE_LOG_PATTERN which is defined in https://github.com/spring-projects/spring-boot/blob/main/spring-boot-project/spring-boot/src/main/resources/org/springframework/boot/logging/logback/defaults.xml
There was a problem hiding this comment.
Moved this file to test/resources so that it applies to unit tests as well (and added a comment clarifying its purpose)
✨ Description of Change
Link to GitHub issue or Jira ticket: https://pihemr.atlassian.net/browse/OBPIH-6858
Description: Disable ANSI Logback colors in prod so that we don't get gross log output like this when the terminal can't parse them properly: