From 6b0f0f8d1e7ad50dad4b6ba3113fe94d8f47a27c Mon Sep 17 00:00:00 2001 From: Brutus5000 Date: Mon, 26 Oct 2026 17:48:58 +0100 Subject: [PATCH 1/4] Log JSON to console by default, plain text for local profile Co-Authored-By: Claude Sonnet 5.5 --- configuration.md | 1 + src/main/resources/config/application-local.yml | 3 +++ src/main/resources/config/application.yml | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/configuration.md b/configuration.md index 10b4da809..b91c16432 100644 --- a/configuration.md +++ b/configuration.md @@ -42,6 +42,7 @@ | LEAGUE_DATABASE_USERNAME | `faf-league-service` | | `faf-league-service` | | LOG_FILE_DIRECTORY | | | | | LOG_LEVEL | `info` | | | +| LOG_STRUCTURED_FORMAT | `ecs` | | Console log format (`ecs`, `logstash`, `gelf`); JSON by default, plain text in the `local` profile | | MAIL_HOST | `false` | | | | MAIL_PASSWORD | `false` | | | | MAIL_PORT | `false` | | | diff --git a/src/main/resources/config/application-local.yml b/src/main/resources/config/application-local.yml index 7f81df781..8815db1eb 100644 --- a/src/main/resources/config/application-local.yml +++ b/src/main/resources/config/application-local.yml @@ -90,5 +90,8 @@ spring: jwk-set-uri: http://hydra.faforever.localhost/.well-known/jwks.json issuer-uri: http://ory-hydra:4444/ logging: + structured: + format: + console: "" level: com.faforever.api: debug diff --git a/src/main/resources/config/application.yml b/src/main/resources/config/application.yml index 1084a55af..fe7212525 100644 --- a/src/main/resources/config/application.yml +++ b/src/main/resources/config/application.yml @@ -180,6 +180,10 @@ management: exposure: include: '*' logging: + structured: + format: + # JSON logs by default (prod/test); the local profile switches back to plain text + console: ${LOG_STRUCTURED_FORMAT:ecs} pattern: console: "%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%36.36X{requestId:- no request context}]){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wEx" level: From 74e73d10fddc80b311f099d8f390db5bf713019e Mon Sep 17 00:00:00 2001 From: Brutus5000 Date: Mon, 26 Oct 2026 17:53:09 +0100 Subject: [PATCH 2/4] Make JSON logging effective: use logback-spring.xml with structured console appender for prod base.xml defined its own pattern-based console appender, bypassing logging.structured.format.console. JSON is now used for the prod profile only. Co-Authored-By: Claude Sonnet 5.5 --- configuration.md | 2 +- .../resources/config/application-local.yml | 3 -- src/main/resources/logback-spring.xml | 40 +++++++++++++++++++ src/main/resources/logback.xml | 20 ---------- 4 files changed, 41 insertions(+), 24 deletions(-) create mode 100644 src/main/resources/logback-spring.xml delete mode 100644 src/main/resources/logback.xml diff --git a/configuration.md b/configuration.md index b91c16432..770bc2746 100644 --- a/configuration.md +++ b/configuration.md @@ -42,7 +42,7 @@ | LEAGUE_DATABASE_USERNAME | `faf-league-service` | | `faf-league-service` | | LOG_FILE_DIRECTORY | | | | | LOG_LEVEL | `info` | | | -| LOG_STRUCTURED_FORMAT | `ecs` | | Console log format (`ecs`, `logstash`, `gelf`); JSON by default, plain text in the `local` profile | +| LOG_STRUCTURED_FORMAT | `ecs` | | Console log format (`ecs`, `logstash`, `gelf`); JSON in the `prod` profile (default), plain text in all other profiles | | MAIL_HOST | `false` | | | | MAIL_PASSWORD | `false` | | | | MAIL_PORT | `false` | | | diff --git a/src/main/resources/config/application-local.yml b/src/main/resources/config/application-local.yml index 8815db1eb..7f81df781 100644 --- a/src/main/resources/config/application-local.yml +++ b/src/main/resources/config/application-local.yml @@ -90,8 +90,5 @@ spring: jwk-set-uri: http://hydra.faforever.localhost/.well-known/jwks.json issuer-uri: http://ory-hydra:4444/ logging: - structured: - format: - console: "" level: com.faforever.api: debug diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml new file mode 100644 index 000000000..a44b23c6e --- /dev/null +++ b/src/main/resources/logback-spring.xml @@ -0,0 +1,40 @@ + + + + + + + + + + ${CONSOLE_LOG_STRUCTURED_FORMAT} + ${CONSOLE_LOG_CHARSET} + + + + + + + + + + + + + + + + ${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}}/audit.log + + audit.%d{yyyy-MM-dd}.log + + + + %d - %msg%n + + + + + + + diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml deleted file mode 100644 index 207ecc281..000000000 --- a/src/main/resources/logback.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - ${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}}/audit.log - - audit.%d{yyyy-MM-dd}.log - - - - %d - %msg%n - - - - - - - From 048477f05b4388a45b3d31afa23ecbb8475bec8b Mon Sep 17 00:00:00 2001 From: Brutus5000 Date: Mon, 26 Oct 2026 17:55:06 +0100 Subject: [PATCH 3/4] Default JSON log format to logstash for Grafana Loki Co-Authored-By: Claude Sonnet 5.5 --- configuration.md | 2 +- src/main/resources/config/application.yml | 2 +- src/main/resources/logback-spring.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configuration.md b/configuration.md index 770bc2746..522d7b966 100644 --- a/configuration.md +++ b/configuration.md @@ -42,7 +42,7 @@ | LEAGUE_DATABASE_USERNAME | `faf-league-service` | | `faf-league-service` | | LOG_FILE_DIRECTORY | | | | | LOG_LEVEL | `info` | | | -| LOG_STRUCTURED_FORMAT | `ecs` | | Console log format (`ecs`, `logstash`, `gelf`); JSON in the `prod` profile (default), plain text in all other profiles | +| LOG_STRUCTURED_FORMAT | `logstash` | | Console log format (`ecs`, `logstash`, `gelf`); JSON in the `prod` profile (default), plain text in all other profiles | | MAIL_HOST | `false` | | | | MAIL_PASSWORD | `false` | | | | MAIL_PORT | `false` | | | diff --git a/src/main/resources/config/application.yml b/src/main/resources/config/application.yml index fe7212525..23f715ae6 100644 --- a/src/main/resources/config/application.yml +++ b/src/main/resources/config/application.yml @@ -183,7 +183,7 @@ logging: structured: format: # JSON logs by default (prod/test); the local profile switches back to plain text - console: ${LOG_STRUCTURED_FORMAT:ecs} + console: ${LOG_STRUCTURED_FORMAT:logstash} pattern: console: "%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%36.36X{requestId:- no request context}]){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wEx" level: diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml index a44b23c6e..690db9605 100644 --- a/src/main/resources/logback-spring.xml +++ b/src/main/resources/logback-spring.xml @@ -1,7 +1,7 @@ - + From b3770300044ffbdf33643f914e98aa792437a4e0 Mon Sep 17 00:00:00 2001 From: Brutus5000 Date: Mon, 26 Oct 2026 17:59:43 +0100 Subject: [PATCH 4/4] Remove logback XML (audit file appender) and rely on Boot structured logging Audit messages still go through the normal console log (logger AuditService). Co-Authored-By: Claude Sonnet 5.5 --- configuration.md | 2 +- .../resources/config/application-local.yml | 3 ++ src/main/resources/logback-spring.xml | 40 ------------------- 3 files changed, 4 insertions(+), 41 deletions(-) delete mode 100644 src/main/resources/logback-spring.xml diff --git a/configuration.md b/configuration.md index 522d7b966..29f9d7211 100644 --- a/configuration.md +++ b/configuration.md @@ -42,7 +42,7 @@ | LEAGUE_DATABASE_USERNAME | `faf-league-service` | | `faf-league-service` | | LOG_FILE_DIRECTORY | | | | | LOG_LEVEL | `info` | | | -| LOG_STRUCTURED_FORMAT | `logstash` | | Console log format (`ecs`, `logstash`, `gelf`); JSON in the `prod` profile (default), plain text in all other profiles | +| LOG_STRUCTURED_FORMAT | `logstash` | | Console log format (`ecs`, `logstash`, `gelf`); JSON by default, plain text in the `local` profile | | MAIL_HOST | `false` | | | | MAIL_PASSWORD | `false` | | | | MAIL_PORT | `false` | | | diff --git a/src/main/resources/config/application-local.yml b/src/main/resources/config/application-local.yml index 7f81df781..8815db1eb 100644 --- a/src/main/resources/config/application-local.yml +++ b/src/main/resources/config/application-local.yml @@ -90,5 +90,8 @@ spring: jwk-set-uri: http://hydra.faforever.localhost/.well-known/jwks.json issuer-uri: http://ory-hydra:4444/ logging: + structured: + format: + console: "" level: com.faforever.api: debug diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml deleted file mode 100644 index 690db9605..000000000 --- a/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - ${CONSOLE_LOG_STRUCTURED_FORMAT} - ${CONSOLE_LOG_CHARSET} - - - - - - - - - - - - - - - - ${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}}/audit.log - - audit.%d{yyyy-MM-dd}.log - - - - %d - %msg%n - - - - - - -