Logback error in Gradle

I am very new to programming, so please dumb it down for me…

I received this error message while creating my project in gradle. I was reading online and they said I should change my logback version to 1.1.6. However, I dont know to do that.

can anyone please help…

thanks

Logging system failed to initialize using configuration from ‘null’
java.lang.IllegalStateException: Logback configuration error detected:
ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - Could not find an appender named [appender_name_IS_UNDEFINED]. Did you define it below instead of above in the configuration file?
ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - See http://logback.qos.ch/codes.html#appender_order for more details.
ERROR in ch.qos.logback.classic.AsyncAppender[ASYNC_CONSOLE] - No attached appenders found

here’s what I was trying to build:

<?xml version="1.0" encoding="UTF-8"?>
<springProperty scope="context" name="appender_name" source="app.logging-to" />

<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
        <pattern>%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) [PID: %clr(${PID:- }){magenta}] %clr(-){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wEx
        </pattern>
        <charset>utf8</charset>
    </encoder>
</appender> 


<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>Cloud-Panel-Logs.log</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        <fileNamePattern>Cloud-Panel-Logs.%d{yyyy-MM}.log</fileNamePattern>
        <maxHistory>6</maxHistory>
        <totalSizeCap>1GB</totalSizeCap>
    </rollingPolicy>

    <encoder>
        <pattern>%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) [PID: %clr(${PID:- }){magenta}] %clr(-){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wEx
        </pattern>
        <charset>utf8</charset>
    </encoder>
</appender>


<appender name="ASYNC_CONSOLE" class="ch.qos.logback.classic.AsyncAppender">
    <appender-ref ref="${appender_name}" />
    <discardingThreshold>0</discardingThreshold>
    <queueSize>100000</queueSize>
    <includeCallerData>false</includeCallerData>
    <neverBlock>false</neverBlock>
</appender>

<root level="INFO">
    <appender-ref ref="ASYNC_CONSOLE" />
</root>

You should most probably not switch to Logback 1.1.6 as that is almost 7 years old.
Current version is 1.4.4.
As you do not show your build scripts, but just your Logback configuration, it is hard to advise how to fix it, but usually you somewhere have a runtimeOnly dependency on logback-classic where you also define which version to use and there you just select the newer version.

Other than that, if you still have a problem with Logback besides how to use a newer version of Logback in your build, you should probably ask in some Logback help channel and not in the Gradle forum. :slight_smile:

Good morning Mr. Kautler,

thank you for replying back to my post…below is the configuration that I had set up. also, I did post a message on logback forum and waiting for a response as well. I’m just trying to get help from anywhere possible. I’m new to programming and for some reason, I just cant see what i’m doing wrong.

so, any help that I can get, would be greatly appreciated…

Thanks

plugins {

id ‘org.springframework.boot’ version ‘2.7.4’

id ‘io.spring.dependency-management’ version ‘1.0.14.RELEASE’

id ‘java’

}

group = ‘com.dolcine’

version = ‘0.0.1-SNAPSHOT’

sourceCompatibility = ‘17’

configurations {

compileOnly {

extendsFrom annotationProcessor

}

}

repositories {

mavenCentral()

}

dependencies {

implementation ‘org.springframework.boot:spring-boot-starter-thymeleaf’

implementation ‘org.springframework.boot:spring-boot-starter-web’

implementation ‘org.springframework.boot:spring-boot-starter-websocket’

implementation ‘com.google.code.gson:gson:2.6.2’

implementation ‘com.google.protobuf:protobuf-java:3.9.0’

implementation ‘org.webjars:jquery:3.4.1’

implementation ‘org.webjars:bootstrap:4.3.1’

implementation ‘org.webjars:webjars-locator-core’

compileOnly ‘org.projectlombok:lombok’

annotationProcessor ‘org.projectlombok:lombok’

testImplementation ‘org.springframework.boot:spring-boot-starter-test’

}

test {

useJUnitPlatform()

}

As a start, I strongly advice not to use the io.spring.dependency-management plugin which is mainly a leftover from Gradle not supporting BOMs natively, but instead use the built-in BOM support removing that plugin and instead having implementation platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES) in the dependencies block.

But either way, what you have is logback-classic 1.2.11 defined through the Spring Boot BOM.
If you want to use a newer version like 1.4.4, you should define a constraint for example having this in the dependencies block:

constraints {
    runtimeOnly 'ch.qos.logback:logback-classic:1.4.4'
}

can I hire you to help me solve this issue. I’ll be more than happy to send you my source code. it’s not much as I am just getting started.

I understand your time is valuable and I’m willing to pay for your assistance.

Sure, just drop me a private message with an offer if you like and we can work something out for sure. :slight_smile:
I never really used Logback as I greatly prefer log4j, but should probably not be all too hard to figure out.