Skip to content

Spring Boot Logback in Docker Container #12667

@anumalasri

Description

@anumalasri

We are using Spring Boot 1.5.9 and logback 1.1.11 and created logback xml based on Spring Profiles.

The configuration works well in Local machine. However in Docker Container, logback is unable to initialize due to error 'Could not find an appender named [CONSOLE]'.

Docker compose has included env property : "SPRING_PROFILES_ACTIVE=dev"

Any clue what could be wrong here..?

<configuration debug='true'>
	<springProperty name='springAppName' source='spring.application.name' defaultValue=' '/> 
    <include resource='org/springframework/boot/logging/logback/defaults.xml' />
    
    <springProfile name='local,dev'>
    	<include resource='org/springframework/boot/logging/logback/console-appender.xml' />    
    </springProfile>
    
    <springProfile name='int,qa,uat,prod'>
	    <appender name='CONSOLE' class='ch.qos.logback.core.ConsoleAppender'>
		    <layout class='ch.qos.logback.classic.PatternLayout'>
				<Pattern>
					%d{yyyy-MM-dd HH:mm:ss.SSS}|severity=%level|pid=${PID:-}||message=%replace(%msg){'\n', '\t'}%n
				</Pattern>
		    </layout>
		</appender>
	</springProfile>
	
    <appender name='Async-Console-Appender' class='ch.qos.logback.classic.AsyncAppender'>
    	<queueSize>512</queueSize>
    	<appender-ref ref='CONSOLE'/>
	</appender>
	
	
    <springProfile name='local,dev,int,qa,uat'> 
		<logger name='org.springframework' level='WARN' additivity='false'>
            <appender-ref ref='Async-Console-Appender' />
        </logger>
		<root level='WARN'>
			<appender-ref ref='Async-Console-Appender' />
		</root>
    </springProfile>
    <springProfile name='production'> 
		<root level='ERROR'>
			<appender-ref ref='Async-Console-Appender' />
		</root>
    </springProfile>
</configuration>

Logs from Docker:

 04:10:41,691 |-INFO in ch.qos.logback.core.joran.util.ConfigurationWatchListUtil@b97c004 - Adding [jar:file:/app.jar!/BOOT-INF/lib/spring-boot-1.5.9.RELEASE.jar!/org/springframework/boot/logging/logback/defaults.xml] to configuration watch list.
 04:10:41,692 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@4590c9c3 - URL [jar:file:/app.jar!/BOOT-INF/lib/spring-boot-1.5.9.RELEASE.jar!/org/springframework/boot/logging/logback/defaults.xml] is not of type file
 04:10:41,723 |-INFO in ch.qos.logback.core.joran.action.ConversionRuleAction - registering conversion word clr with class [org.springframework.boot.logging.logback.ColorConverter]
 04:10:41,723 |-INFO in ch.qos.logback.core.joran.action.ConversionRuleAction - registering conversion word wex with class [org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter]
 04:10:41,727 |-INFO in ch.qos.logback.core.joran.action.ConversionRuleAction - registering conversion word wEx with class [org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter]
 04:10:41,729 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [org.springframework.boot.logging.logback.LevelRemappingAppender]
 04:10:41,734 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [DEBUG_LEVEL_REMAPPER]
 04:10:41,764 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.catalina.startup.DigesterFactory] to ERROR
 04:10:41,764 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@5afa04c - Propagating ERROR level on Logger[org.apache.catalina.startup.DigesterFactory] onto the JUL framework
 04:10:41,771 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.catalina.util.LifecycleBase] to ERROR
 04:10:41,772 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@5afa04c - Propagating ERROR level on Logger[org.apache.catalina.util.LifecycleBase] onto the JUL framework
 04:10:41,774 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.coyote.http11.Http11NioProtocol] to WARN
 04:10:41,774 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@5afa04c - Propagating WARN level on Logger[org.apache.coyote.http11.Http11NioProtocol] onto the JUL framework
 04:10:41,777 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.sshd.common.util.SecurityUtils] to WARN
 04:10:41,777 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@5afa04c - Propagating WARN level on Logger[org.apache.sshd.common.util.SecurityUtils] onto the JUL framework
 04:10:41,778 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.tomcat.util.net.NioSelectorPool] to WARN
 04:10:41,778 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@5afa04c - Propagating WARN level on Logger[org.apache.tomcat.util.net.NioSelectorPool] onto the JUL framework
 04:10:41,779 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.crsh.plugin] to WARN
 04:10:41,784 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@5afa04c - Propagating WARN level on Logger[org.crsh.plugin] onto the JUL framework
 04:10:41,785 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.crsh.ssh] to WARN
 04:10:41,785 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@5afa04c - Propagating WARN level on Logger[org.crsh.ssh] onto the JUL framework
 04:10:41,785 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.eclipse.jetty.util.component.AbstractLifeCycle] to ERROR
 04:10:41,785 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@5afa04c - Propagating ERROR level on Logger[org.eclipse.jetty.util.component.AbstractLifeCycle] onto the JUL framework
 04:10:41,787 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.hibernate.validator.internal.util.Version] to WARN
 04:10:41,787 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@5afa04c - Propagating WARN level on Logger[org.hibernate.validator.internal.util.Version] onto the JUL framework
 04:10:41,788 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.springframework.boot.actuate.autoconfigure.CrshAutoConfiguration] to WARN
 04:10:41,789 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@5afa04c - Propagating WARN level on Logger[org.springframework.boot.actuate.autoconfigure.CrshAutoConfiguration] onto the JUL framework
 04:10:41,790 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.springframework.boot.actuate.endpoint.jmx] to false
 04:10:41,791 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [DEBUG_LEVEL_REMAPPER] to Logger[org.springframework.boot.actuate.endpoint.jmx]
 04:10:41,792 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.thymeleaf] to false
 04:10:41,792 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [DEBUG_LEVEL_REMAPPER] to Logger[org.thymeleaf]
 04:10:41,805 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.classic.AsyncAppender]
 04:10:41,828 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [Async-Console-Appender]
 **04:10:41,833 |-ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - Could not find an appender named [CONSOLE]. Did you define it below instead of above in the configuration file?**
 04:10:41,833 |-ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - See http://logback.qos.ch/codes.html#appender_order for more details.
 04:10:41,836 |-ERROR in ch.qos.logback.classic.AsyncAppender[Async-Console-Appender] - No attached appenders found.
 04:10:41,848 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
 04:10:41,849 |-INFO in org.springframework.boot.logging.logback.SpringBootJoranConfigurator@5ae9a829 - Registering current configuration as safe fallback point
service_1 exited with code 1

Logs from Local Machine:

00:20:13,500 |-INFO in ch.qos.logback.core.joran.util.ConfigurationWatchListUtil@6cdba6dc - Adding [jar:file:/D:/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot/1.5.9.RELEASE/f472cdf948288796fb31e0bb03f6e7b022b763a0/spring-boot-1.5.9.RELEASE.jar!/org/springframework/boot/logging/logback/console-appender.xml] to configuration watch list.
00:20:13,500 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@7d3d101b - URL [jar:file:/D:/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot/1.5.9.RELEASE/f472cdf948288796fb31e0bb03f6e7b022b763a0/spring-boot-1.5.9.RELEASE.jar!/org/springframework/boot/logging/logback/console-appender.xml] is not of type file
00:20:13,502 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
00:20:13,503 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [CONSOLE]
00:20:13,505 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
00:20:13,592 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.classic.AsyncAppender]
00:20:13,596 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [Async-Console-Appender]
00:20:13,599 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [CONSOLE] to ch.qos.logback.classic.AsyncAppender[Async-Console-Appender]
00:20:13,599 |-INFO in ch.qos.logback.classic.AsyncAppender[Async-Console-Appender] - Attaching appender named [CONSOLE] to AsyncAppender.
00:20:13,599 |-INFO in ch.qos.logback.classic.AsyncAppender[Async-Console-Appender] - Setting discardingThreshold to 102

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: invalidAn issue that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions