[D] Support Kotlin’s "Unused Return Value" Warning s for improved developer experience [logging-log4j2]
daniel-morgenstern (via GitHub) <[email protected]> Wed, 21 Jan 2026 08:57:50 -0000
| Newsgroups | gmane.comp.jakarta.log4j.devel |
|---|---|
| Message-ID | <ghd-D_kwDOAKJSSM4Ajvts__11696.893086058$1768985927$gmane$org@gitbox.apache.org> |
GitHub user daniel-morgenstern created a discussion: Support Kotlin’s "Unused Return Value" Warnings for improved developer experience
Kotlin provides a feature that allows APIs to indicate that a return value **must be used**. When this is enabled via an annotation, the Kotlin compiler can emit warnings if a caller ignores the return value.
Applying this annotation in Log4j could help prevent subtle logging mistakes. For example, consider the following code (missing `.log()`):
```kotlin
log.atInfo().setMessage("Some sample message")
```
By marking the return value of all builder methods as “must be used,” the Kotlin compiler could emit warnings for incomplete fluent logging statements. This would make such issues detectable at compile time and improve the overall developer experience for Kotlin users working with fluent Log4j APIs.
You can get more information about this here: https://kotlinlang.org/docs/unused-return-value-checker.html
GitHub link: https://github.com/apache/logging-log4j2/discussions/4027
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]