Skip to content
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.

Refine Logback XML support documentation #1303

Closed
kwencel opened this issue Nov 25, 2021 · 3 comments
Closed

Refine Logback XML support documentation #1303

kwencel opened this issue Nov 25, 2021 · 3 comments
Assignees
Labels
type: documentation A documentation task
Milestone

Comments

@kwencel
Copy link

kwencel commented Nov 25, 2021

From what I read here you started to support external Logback XML configuration in 0.11.0-RC1.

However, when I run a Spring Boot 2.6.0 app with 0.11.0-R1 Gradle plugin and removeXmlSupport set to false, with the following arguments:

-Duser.timezone=Europe/Warsaw
-Duser.language=pl
-Duser.country=PL
-Dcom.sun.management.jmxremote.port=3000
-Dcom.sun.management.jmxremote.rmi.port=3000
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Djava.rmi.server.hostname=127.0.0.1
-Dcom.sun.management.jmxremote.local.only=true
-Dlogging.config=file:///app/config/logs/logback.xml
-Dserver.address=0.0.0.0
-Dserver.port=8080
-Dmanagement.server.address=0.0.0.0
-Dmanagement.server.port=8081
-Dmanagement.endpoints.web.base-path=/
-Dspring.config.additional-location=/app/config/
-Dspring.profiles.active=k8s

it displays the following message:

Logging system failed to initialize using configuration from 'file:///app/config/logs/logback.xml'
java.lang.IllegalStateException: Logback configuration error detected:
ERROR in ch.qos.logback.core.joran.action.AppenderAction - Could not create an Appender of type [ch.qos.logback.core.ConsoleAppender]. ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.core.ConsoleAppender
ERROR in ch.qos.logback.core.joran.spi.Interpreter@9:71 - ActionException in Action for tag [appender] ch.qos.logback.core.joran.spi.ActionException: ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.core.ConsoleAppender
ERROR in ch.qos.logback.core.joran.action.AppenderAction - Could not create an Appender of type [ch.qos.logback.core.ConsoleAppender]. ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.core.ConsoleAppender
ERROR in ch.qos.logback.core.joran.spi.Interpreter@6:73 - ActionException in Action for tag [appender] ch.qos.logback.core.joran.spi.ActionException: ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.core.ConsoleAppender
ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - Could not find an appender named [STDOUT]. 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.
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:179)
    at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithSpecificConfig(AbstractLoggingSystem.java:66)
    at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:57)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:132)
    at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:316)
    at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:282)
    at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:240)
    at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:216)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:85)
    at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:66)
    at java.util.ArrayList.forEach(ArrayList.java:1541)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:120)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:114)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:65)
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:338)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:296)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1290)
    at <redacted>.ApplicationKt.main(Application.kt:51)

The /app/config/logs/logback.xml looks looks like this:

<configuration>
  <include resource="org/springframework/boot/logging/logback/defaults.xml"/>
  <include resource="org/springframework/boot/logging/logback/console-appender.xml"/>

  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
      <encoder>
          <pattern>${CONSOLE_LOG_PATTERN}</pattern>
          <charset>utf8</charset>
      </encoder>
  </appender>

  <root level="INFO">
      <appender-ref ref="STDOUT"/>
  </root>
</configuration>

So it definitely reads the file but seems to be unable to instantiate the ch.qos.logback.core.ConsoleAppender class. What should I do in this case?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Nov 25, 2021
@kwencel kwencel changed the title Problem with Logback XML support in 0.10.0-RC1 Problem with Logback XML support in 0.11.0-RC1 Nov 25, 2021
@sdeleuze sdeleuze self-assigned this Dec 6, 2021
@sdeleuze sdeleuze added this to the 0.11.0 milestone Dec 6, 2021
@sdeleuze sdeleuze added type: documentation A documentation task and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Dec 6, 2021
@sdeleuze sdeleuze changed the title Problem with Logback XML support in 0.11.0-RC1 Refine Logback XML support documentation Dec 6, 2021
@sdeleuze
Copy link
Contributor

sdeleuze commented Dec 6, 2021

You probably miss the org.codehaus.janino:janino dependency, I will refine the documentation to clarify it is required. With that I validated it works as expected.

@13940344135
Copy link

13940344135 commented Mar 3, 2022

You probably miss the org.codehaus.janino:janino dependency, I will refine the documentation to clarify it is required. With that I validated it works as expected.

@sdeleuze
After adding org.codehaus.janino:janino:3.1.6 dependency, Error: Main entry point class 'example.staveware.stvwebstore.Application' not found. will happen when compile, please help.

@sdeleuze
Copy link
Contributor

sdeleuze commented Mar 7, 2022

Hi, likely unrelated, I recommend starting a project from start.spring.io to be sure it is correct or check our logger sample.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: documentation A documentation task
Development

No branches or pull requests

4 participants