Skip to content

Commit

Permalink
docs(cli): Explain SLF4J API usage in addition to Log4j API usage
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
  • Loading branch information
sschuberth committed Aug 27, 2024
1 parent 602ab3c commit 99cd187
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cli/src/main/kotlin/OrtMain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ class OrtMain : CliktCommand(
}

override fun run() {
// This is somewhat dirty: For logging, ORT uses the Log4j API (because of its nice Kotlin API), but Logback as
// the implementation (for its robustness). The former API does not provide a way to set the root log level,
// only the Log4j implementation does (via org.apache.logging.log4j.core.config.Configurator). However, the
// SLF4J API does provide a way to get the root logger and set its level. That is why ORT's CLI additionally
// depends on the SLF4J API, just to be able to set the root log level below.
val rootLogger = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME) as Logger
rootLogger.level = logLevel

Expand Down
5 changes: 5 additions & 0 deletions helper-cli/src/main/kotlin/HelperMain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ internal class HelperMain : CliktCommand(
}

override fun run() {
// This is somewhat dirty: For logging, ORT uses the Log4j API (because of its nice Kotlin API), but Logback as
// the implementation (for its robustness). The former API does not provide a way to set the root log level,
// only the Log4j implementation does (via org.apache.logging.log4j.core.config.Configurator). However, the
// SLF4J API does provide a way to get the root logger and set its level. That is why ORT's CLI additionally
// depends on the SLF4J API, just to be able to set the root log level below.
val rootLogger = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME) as Logger
rootLogger.level = logLevel

Expand Down

0 comments on commit 99cd187

Please sign in to comment.