Skip to content

Launch app with log4j2 support not generating a proper project template #2686

@erdincyilmazel

Description

@erdincyilmazel

Expected Behavior

I just created a new project using the micronaut launch app, added log4j2 as an option. When I start the generated empty project as is, I am getting an error from SL4J that says No SLF4J providers were found. Obviously, logging doesn't work. I can't tell exactly where the problem is, as the log4j dependencies are clearly in the gradle build file:

    annotationProcessor("io.micronaut:micronaut-http-validation")
    annotationProcessor("io.micronaut.serde:micronaut-serde-processor")
    implementation("io.micronaut.serde:micronaut-serde-jackson")
    implementation("org.apache.logging.log4j:log4j-api")
    implementation(platform("org.apache.logging.log4j:log4j-bom:2.24.1"))
    compileOnly("io.micronaut:micronaut-http-client")
    runtimeOnly("org.apache.logging.log4j:log4j-core")
    runtimeOnly("org.apache.logging.log4j:log4j-slf4j-impl")
    testImplementation("io.micronaut:micronaut-http-client")

Actual Behaviour

I expect slf4j to pickup log4j2 as the logger. I am getting a NoOp logger at runtime instead.

Steps To Reproduce

Go to https://micronaut.io/launch, on features add log4j2 and then generate a project.

Console output when I first run the blank app:

SLF4J(W): No SLF4J providers were found.
SLF4J(W): Defaulting to no-operation (NOP) logger implementation
SLF4J(W): See https://www.slf4j.org/codes.html#noProviders for further details.
 __  __ _                                  _   
|  \/  (_) ___ _ __ ___  _ __   __ _ _   _| |_ 
| |\/| | |/ __| '__/ _ \| '_ \ / _` | | | | __|
| |  | | | (__| | | (_) | | | | (_| | |_| | |_ 
|_|  |_|_|\___|_|  \___/|_| |_|\__,_|\__,_|\__|

Environment Information

No response

Example Application

No response

Version

4.7.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions