Replace unmaintained deps: Spek2→Kotest, logback-contrib→JsonEncoder#112
Replace unmaintained deps: Spek2→Kotest, logback-contrib→JsonEncoder#112
Conversation
…nEncoder - Migrate test framework from Spek2 (stagnant since 2021) to Kotest DescribeSpec - Replace logback-contrib JSON logging with logback 1.5+ built-in JsonEncoder - Remove duplicate kotlin-stdlib-jdk8 declarations - Simplify test helpers and remove duplicate test rows
📝 WalkthroughWalkthroughThis PR migrates the test framework from Spek to Kotest, updates logging configuration and dependencies, and applies minor refactoring. The test suite is restructured from Spek's object-based approach to Kotest's DescribeSpec class-based pattern while preserving test logic. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/main/resources/logback.xml`:
- Line 4: The logback configuration now uses the built-in JsonEncoder (encoder
class="ch.qos.logback.classic.encoder.JsonEncoder") so remove the
now-unnecessary dependencies (logback-json-classic and logback-gson-formatter)
from the build configuration, ensure Logback is upgraded to v1.5.29+ in your
dependency manifest, and validate/adjust any log ingestion pipelines or
dashboards that relied on the prior JsonLayout+GsonFormatter schema (update
mappings or configure JsonEncoder properties to match expected field/timestamp
names if needed).
| <appendLineSeparator>true</appendLineSeparator> | ||
| </layout> | ||
| </encoder> | ||
| <encoder class="ch.qos.logback.classic.encoder.JsonEncoder"/> |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# Check build.gradle.kts for logback version and dependencies
find . -name "build.gradle.kts" -type f | head -5Repository: blindern/users-api
Length of output: 80
🏁 Script executed:
# Also check for build.gradle files
find . -name "build.gradle" -type f | head -5Repository: blindern/users-api
Length of output: 44
🏁 Script executed:
# Search for logback dependencies in gradle files
rg "logback" -t gradleRepository: blindern/users-api
Length of output: 210
🏁 Script executed:
# Read build.gradle.kts to check logback version
cat build.gradle.ktsRepository: blindern/users-api
Length of output: 2753
🏁 Script executed:
# Search for logback references in all files
rg "logback" -A 2 -B 2Repository: blindern/users-api
Length of output: 870
🏁 Script executed:
# Check the actual logback.xml file
cat src/main/resources/logback.xmlRepository: blindern/users-api
Length of output: 398
🏁 Script executed:
# Check git history to see what changed
git log --oneline -n 20 -- src/main/resources/logback.xml build.gradle.kts 2>/dev/null || echo "Git history not available"Repository: blindern/users-api
Length of output: 147
🏁 Script executed:
# Check git diff to see what was removed/added
git diff HEAD~5..HEAD -- src/main/resources/logback.xml build.gradle.kts 2>/dev/null | head -100 || echo "Git diff not available"Repository: blindern/users-api
Length of output: 44
🌐 Web query:
logback JsonEncoder 1.5 introduction release notes
💡 Result:
JsonEncoder was not first introduced in Logback 1.5.x. It first appeared in the release notes for Logback 1.3.8 / 1.4.8 (2023-06-13): “Logback now ships with JsonEncoder … in Newline delimited JSON (ndjson) format.” [1]
In the Logback 1.5.0 release (2024-02-16), the release notes call out JsonEncoder enhancements: you can enable/disable all top-level JSON members, and an optional (disabled-by-default) "formattedMessage" member was added. [1]
Related 1.5.x JsonEncoder notes include:
- 1.5.10 (2024-10-12): fix for invalid JSON when some fields (notably
throwable) are disabled. [1] - 1.5.21 (2025-11-10):
JsonEncodermade friendlier for subclassing. [1]
Source: Logback News / release notes page. [1]
🌐 Web query:
logback JsonLayout GsonFormatter vs JsonEncoder differences
💡 Result:
1) ch.qos.logback.contrib.json.classic.JsonLayout (logback-contrib)
- Type: Layout (produces a JSON string); typically used via
LayoutWrappingEncoder(i.e., it’s not anEncoderitself). - JSON library: Pluggable via
jsonFormatter(commonlych.qos.logback.contrib.jackson.JacksonJsonFormatter). [1] - Status / direction: The logback-contrib project was archived, and logback maintainers point people to Logback’s built-in
JsonEncoderas an alternative. [2]
2) GsonFormatter (usually: de.gessnerfl.logback:logback-gson-formatter)
- What it is: A third‑party JSON formatter module that plugs into logback-contrib’s
JsonLayoutto serialize via Google Gson (instead of Jackson). It depends onlogback-json-coreandgson. [3] - Scope: It does not replace
JsonLayout; it’s only the formatter used byJsonLayout.
3) ch.qos.logback.classic.encoder.JsonEncoder (built into Logback)
- Type: Encoder (writes bytes directly) and outputs JSON Lines (one JSON object per log event/line). [4][1]
- Configuration model: Lots of boolean switches to include/exclude fields (timestamp, MDC, markers, arguments, throwable/stacktrace, etc.). [4]
- Key practical difference vs
JsonLayout: This is now the “native” Logback JSON option (no logback-contrib layout/formatter layering). [2][1]
Quick “which should I use?” rule of thumb
- Want built-in Logback JSON with JSON Lines and configurable standard fields → Logback
JsonEncoder. [4][1] - You already use logback-contrib
JsonLayoutand just want Gson instead of Jackson →JsonLayout+ Gson formatter module. [3][1] - Need Logstash-focused JSON with rich structured logging features (providers/composite encoders, custom fields, etc.) → consider logstash-logback-encoder (
LogstashEncoder/ composite encoders). [5]
Sources
[1] Logback manual – Encoders / JsonEncoder section: https://logback.qos.ch/manual/encoders.html
[2] logback-user mailing list (May 17, 2024): logback-contrib archived; suggestion to use Logback JsonEncoder: https://mailman3.qos.ch/hyperkitty/list/logback-user%40qos.ch/thread/T2FRI3KDO3P4ASML464I77TKSBD6QFSE/
[3] Maven artifact for third-party Gson formatter (deps include logback-json-core + gson): https://mvnrepository.com/artifact/de.gessnerfl.logback/logback-gson-formatter
[4] Logback Javadoc / source overview for ch.qos.logback.classic.encoder.JsonEncoder (configurable included fields): https://logback.qos.ch/apidocs/ch.qos.logback.classic/ch/qos/logback/classic/encoder/JsonEncoder.html
[5] logstash-logback-encoder README (encoders/layouts, customization, composite encoders/providers): https://github.com/logfellow/logstash-logback-encoder
LGTM — clean migration to built-in JsonEncoder.
This removes the need for the unmaintained logback-json-classic and logback-gson-formatter dependencies. The JsonEncoder is built into Logback and fully supported by version 1.5.29.
Note: The JSON output format from JsonEncoder will likely differ from the previous JsonLayout+GsonFormatter combination (different field names, structure, timestamp format). If any log aggregation pipelines or dashboards depend on the specific JSON schema, they may need updating.
🤖 Prompt for AI Agents
In `@src/main/resources/logback.xml` at line 4, The logback configuration now uses
the built-in JsonEncoder (encoder
class="ch.qos.logback.classic.encoder.JsonEncoder") so remove the
now-unnecessary dependencies (logback-json-classic and logback-gson-formatter)
from the build configuration, ensure Logback is upgraded to v1.5.29+ in your
dependency manifest, and validate/adjust any log ingestion pipelines or
dashboards that relied on the prior JsonLayout+GsonFormatter schema (update
mappings or configure JsonEncoder properties to match expected field/timestamp
names if needed).
Summary
DescribeSpec, which has near-identicaldescribe/itsyntax. Already usedkotest-assertions-corefor matchers.logback-json-classic(last release 2016) andlogback-gson-formatterwith logback 1.5+ built-inJsonEncoder.kotlin-stdlib-jdk8declarations (unnecessary in Kotlin 2.x).associateinstead ofmap{}.toMap().🤖 Generated with Claude Code
Summary by CodeRabbit