I am developing a Keycloak SPI (Service Provider Interface) and need to log specific events to a different file using SLF4J markers. However, I am facing issues integrating Logback with Keycloak's default Quarkus logging system.
My setup: Keycloak uses Quarkus, which has its own built-in logging system. I am trying to use Logback to handle logging in my SPI. I placed a logback.xml file inside src/main/resources/. However, my logs are still printed using the default Quarkus logger instead of Logback. Project structure:
my-custom-spi/
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── com/example/
│ │ │ └── MyCustomProvider.java
│ │ └── resources/
│ │ └── logback.xml
│ └── test/
│ └── java/
├── build.gradle
└── build/
└── libs/
└── my-custom-spi.jar
build.gradle:
plugins {
id 'java'
}
repositories {
mavenCentral()
}
dependencies {
// Keycloak SPI dependencies
implementation '.keycloak:keycloak-core:21.1.2'
implementation '.keycloak:keycloak-server-spi:21.1.2'
implementation '.keycloak:keycloak-server-spi-private:21.1.2'
// Logback dependencies
implementation 'ch.qos.logback:logback-classic:1.2.11' // Logback implementation
implementation '.slf4j:slf4j-api:1.7.36' // SLF4J API
}
jar {
archiveFileName = 'my-custom-spi.jar'
}
Issue: Even after adding Logback dependencies and placing logback.xml in src/main/resources, the logs still appear in the default Quarkus logging format seems like logback has no effect SLF4J logs don't seem to be routed through Logback.
Question: How can I configure Logback in a Keycloak SPI so that specific logs (using SLF4J markers) go to a separate file? Do I need to disable Quarkus logging or perform additional configurations to make Logback work? Is there a way to force Keycloak to use Logback instead of the default Quarkus logger? Any insights or working solutions would be appreciated!