Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace the Log4j implementation with Logback #5673

Merged
merged 7 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ subprojects {
// Ensure all OkHttp versions match our version >= 4 to avoid Kotlin vs. Java issues with OkHttp 3.
force(rootProject.libs.okhttp)

// Ensure all API library versions match our core library version.
// Ensure all Log4j API versions match our version.
force(rootProject.libs.log4jApi)

// Ensure that all transitive versions of Kotlin libraries match our version of Kotlin.
Expand Down Expand Up @@ -243,7 +243,7 @@ subprojects {
jdkVersion.set(11)

val jacksonVersion = libs.versions.jackson.get()
val log4jVersion = libs.versions.log4j.get()
val log4jApiVersion = libs.versions.log4jApi.get()

externalDocumentationLink {
val baseUrl = "https://codehaus-plexus.github.io/plexus-containers/plexus-container-default/apidocs"
Expand All @@ -265,7 +265,7 @@ subprojects {
}

externalDocumentationLink {
val majorVersion = log4jVersion.substringBefore('.')
val majorVersion = log4jApiVersion.substringBefore('.')
val baseUrl = "https://logging.apache.org/log4j/$majorVersion.x/log4j-api/apidocs"
url.set(URL(baseUrl))
packageListUrl.set(URL("$baseUrl/package-list"))
Expand Down
4 changes: 2 additions & 2 deletions cli/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ dependencies {
implementation(libs.jacksonDatabind)
implementation(libs.jacksonModuleKotlin)
implementation(libs.kotlinxCoroutines)
implementation(libs.log4jCore)
implementation(libs.log4jImplSlf4j)
implementation(libs.log4jApiToSlf4j)
implementation(libs.logbackClassic)
implementation(libs.postgres)
implementation(libs.reflections)
implementation(libs.sw360Client)
Expand Down
11 changes: 7 additions & 4 deletions cli/src/main/kotlin/OrtMain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

package org.ossreviewtoolkit.cli

import ch.qos.logback.classic.Level
import ch.qos.logback.classic.Logger

import com.github.ajalt.clikt.completion.completionOption
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.context
Expand All @@ -39,9 +42,6 @@ import java.io.File

import kotlin.system.exitProcess

import org.apache.logging.log4j.Level
import org.apache.logging.log4j.core.config.Configurator

import org.ossreviewtoolkit.cli.commands.*
import org.ossreviewtoolkit.cli.utils.logger
import org.ossreviewtoolkit.model.config.LicenseFilenamePatterns
Expand All @@ -57,6 +57,8 @@ import org.ossreviewtoolkit.utils.ort.ortConfigDirectory
import org.ossreviewtoolkit.utils.ort.ortDataDirectory
import org.ossreviewtoolkit.utils.ort.printStackTrace

import org.slf4j.LoggerFactory

/**
* Helper class for mutually exclusive command line options of different types.
*/
Expand Down Expand Up @@ -171,7 +173,8 @@ class OrtMain : CliktCommand(name = ORT_NAME, invokeWithoutSubcommand = true) {
}

override fun run() {
Configurator.setRootLevel(logLevel)
val rootLogger = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME) as Logger
rootLogger.level = logLevel

logger.debug { "Used command line arguments: ${currentContext.originalArgv}" }

Expand Down
296 changes: 296 additions & 0 deletions cli/src/main/resources/META-INF/native-image/reflect-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,296 @@
[
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.classic.pattern.CallerDataConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.classic.pattern.CallerDataConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.classic.pattern.ClassOfCallerConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.classic.pattern.ContextNameConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.classic.pattern.DateConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.classic.pattern.ExtendedThrowableProxyConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.classic.pattern.FileOfCallerConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.classic.pattern.LevelConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.classic.pattern.LineOfCallerConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.classic.pattern.LineSeparatorConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.classic.pattern.LocalSequenceNumberConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.classic.pattern.LoggerConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.classic.pattern.MDCConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.classic.pattern.MarkerConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.classic.pattern.MessageConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.classic.pattern.MethodOfCallerConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.classic.pattern.NopThrowableInformationConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.classic.pattern.PrefixCompositeConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.classic.pattern.PropertyConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.classic.pattern.RelativeTimeConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.classic.pattern.RootCauseFirstThrowableProxyConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.classic.pattern.ThreadConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.classic.pattern.ThrowableProxyConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.classic.pattern.color.HighlightingCompositeConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.core.pattern.IdentityCompositeConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.core.pattern.ReplacingCompositeConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.core.pattern.color.BlackCompositeConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.core.pattern.color.BlueCompositeConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.core.pattern.color.BoldBlueCompositeConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.core.pattern.color.BoldCyanCompositeConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.core.pattern.color.BoldGreenCompositeConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.core.pattern.color.BoldMagentaCompositeConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.core.pattern.color.BoldRedCompositeConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.core.pattern.color.BoldWhiteCompositeConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.core.pattern.color.BoldYellowCompositeConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.core.pattern.color.CyanCompositeConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.core.pattern.color.GrayCompositeConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.core.pattern.color.GreenCompositeConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.core.pattern.color.MagentaCompositeConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.core.pattern.color.RedCompositeConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.core.pattern.color.WhiteCompositeConverter",
"allPublicConstructors": true
},
{
"condition": {
"typeReachable": "ch.qos.logback.classic.LoggerContext"
},
"name": "ch.qos.logback.core.pattern.color.YellowCompositeConverter",
"allPublicConstructors": true
}
]
Loading