Logback configuration error when running Spring boot on linux vm - windows vm is ok - spring-boot

I have a spring boot app hosted on an azure app service which starts fine on a windows vm but on linux vm I get this logback error (scroll down for full stacktrace):
2022-08-09T21:04:41.0995698 Caused by: java.lang.IllegalStateException: Logback configuration error detected:
2022-08-09T21:04:41.0995738 ERROR in c******#3:104 - no applicable action for [springProperty], current ElementPath is [[configuration][springProperty]]
Using:
org.springframework.boot:spring-boot:2.3.7.RELEASE
ch.qos.logback:logback-core:1.2.3
I'm just putting this out there, in case anyone has seen this before. Next steps for me would be to either set-up remote debugger to azure or set-up a local linux vm to test.
logback.xml:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<springProperty scope="context" name="instrumentationKey" source="appinsights.instrumentationkey"/>
<statusListener class="ch.qos.logback.core.status.NopStatusListener"/>
<springProfile name="logging-azure">
<appender name="aiAppender" class="com.microsoft.applicationinsights.logback.ApplicationInsightsAppender">
<instrumentationKey>${instrumentationKey}</instrumentationKey>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
</appender>
</springProfile>
<!-- Initial Parent Folder -->
<variable name="logfilePath" value="br-proposition-logs"/>
<include resource="standard-logback-config.xml"/>
<springProfile name="logging-local">
<root level="ERROR">
<appender-ref ref="STDOUT"/>
<appender-ref ref="LOG-FILE"/>
</root>
</springProfile>
<springProfile name="logging-azure">
<root level="ERROR">
<appender-ref ref="aiAppender"/>
<appender-ref ref="LOG-FILE"/>
</root>
</springProfile>
</configuration>
and standard-logback-config.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<included>
<variable name="fileName" value="br-proposition"/>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%X{proposition.requestId}] %-5level %logger %marker %msg%n</pattern>
</encoder>
</appender>
<appender name="LOG-FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${logfilePath}/${fileName}.log</file>
<rollingPolicy class="com.lv.gi.traps.common.logging.TrapsSizeAndTimeBasedRollingPolicy">
<FileNamePattern>${logfilePath}/%d{yyyy-MM-dd,aux}/${fileName}.%d{yyyy-MM-dd}-%i.log</FileNamePattern>
<maxFileSize>20MB</maxFileSize>
<maxHistory>7</maxHistory>
<totalSizeCap>1GB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder>
<pattern>%d [${HOSTNAME}:%X{proposition.requestId}] %-5level %logger %marker %msg%n</pattern>
</encoder>
</appender>
</included>
Full stacktrace:
2022-08-09T21:04:41.0994993 Exception in thread "main" java.lang.reflect.InvocationTargetException
2022-08-09T21:04:41.0995272 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2022-08-09T21:04:41.099543 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
2022-08-09T21:04:41.0995473 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2022-08-09T21:04:41.0995512 at java.base/java.lang.reflect.Method.invoke(Method.java:566)
2022-08-09T21:04:41.0995549 at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
2022-08-09T21:04:41.0995588 at org.springframework.boot.loader.Launcher.launch(Launcher.java:107)
2022-08-09T21:04:41.0995625 at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
2022-08-09T21:04:41.0995661 at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
2022-08-09T21:04:41.0995698 Caused by: java.lang.IllegalStateException: Logback configuration error detected:
2022-08-09T21:04:41.0995738 ERROR in c****#3:104 - no applicable action for [springProperty], current ElementPath is [[configuration][springProperty]]**
2022-08-09T21:04:41.0995776 ERROR in c******#6:41 - no applicable action for [springProfile], current ElementPath is [[configuration][springProfile]]
2022-08-09T21:04:41.0995815 ERROR in c******#7:115 - no applicable action for [appender], current ElementPath is [[configuration][springProfile][appender]]
2022-08-09T21:04:41.0995854 ERROR in c******#8:33 - no applicable action for [instrumentationKey], current ElementPath is [[configuration][springProfile][appender][instrumentationKey]]
2022-08-09T21:04:41.0995894 ERROR in c******#9:75 - no applicable action for [filter], current ElementPath is [[configuration][springProfile][appender][filter]]
2022-08-09T21:04:41.0995933 ERROR in c******#10:24 - no applicable action for [level], current ElementPath is [[configuration][springProfile][appender][filter][level]]
2022-08-09T21:04:41.0995971 ERROR in c******#20:41 - no applicable action for [springProfile], current ElementPath is [[configuration][springProfile]]
2022-08-09T21:04:41.0996017 ERROR in c******#21:29 - no applicable action for [root], current ElementPath is [[configuration][springProfile][root]]
2022-08-09T21:04:41.0996057 ERROR in c******#22:41 - no applicable action for [appender-ref], current ElementPath is [[configuration][springProfile][root][appender-ref]]
2022-08-09T21:04:41.0996095 ERROR in c******#23:43 - no applicable action for [appender-ref], current ElementPath is [[configuration][springProfile][root][appender-ref]]
2022-08-09T21:04:41.0996135 ERROR in c******#27:41 - no applicable action for [springProfile], current ElementPath is [[configuration][springProfile]]
2022-08-09T21:04:41.0996174 ERROR in c******#28:29 - no applicable action for [root], current ElementPath is [[configuration][springProfile][root]]
2022-08-09T21:04:41.099624 ERROR in c******#29:45 - no applicable action for [appender-ref], current ElementPath is [[configuration][springProfile][root][appender-ref]]
2022-08-09T21:04:41.0996281 ERROR in c******#30:43 - no applicable action for [appender-ref], current ElementPath is [[configuration][springProfile][root][appender-ref]]
2022-08-09T21:04:41.0996321 at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:169)
2022-08-09T21:04:41.0996359 at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:80)
2022-08-09T21:04:41.0996397 at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:60)
2022-08-09T21:04:41.0996434 at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:118)
2022-08-09T21:04:41.0996471 at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:306)
2022-08-09T21:04:41.0996509 at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:281)
2022-08-09T21:04:41.0996547 at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:239)
2022-08-09T21:04:41.0996589 at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:216)
2022-08-09T21:04:41.0996628 at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
2022-08-09T21:04:41.0996666 at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
2022-08-09T21:04:41.0996705 at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
2022-08-09T21:04:41.0996742 at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
2022-08-09T21:04:41.099678 at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:80)
2022-08-09T21:04:41.0996818 at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53)
2022-08-09T21:04:41.0996856 at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:345)
2022-08-09T21:04:41.0996897 at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
2022-08-09T21:04:41.0996934 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237)
2022-08-09T21:04:41.0996971 at com.lv.gi.propositionengine.PropositionEngineInitializer.initialise(PropositionEngineInitializer.java:20)
2022-08-09T21:04:41.0997009 at com.lv.gi.br.propositionengine.AppPropositionEngineApplication.main(AppPropositionEngineApplication.java:28)
2022-08-09T21:04:41.0997074 ... 8 more

This issue was fixed by renaming logback.xml to logback-spring.xml I’m not able to explain why this was only necessary when the jar ran on Linux but not on windows. It works now on both OS’s.
The logback-spring.xml name is recommended by Spring in the spring boot documentation ensuring spring beans required by logback are initialised in time.

Related

issues with logback using springboot

please help me...I'm new to programming so please dumb it down for me.
I'm building a project and below is my code. however, I keep getting an error message that's included below.
Now I saw a previous thread that says I should use an earlier version of logback, but I dont now how to change it to the previous version. Can someone please walk me through it. I would really appreciate an fix to my problem so that I can move forward.
Thanks
Error message:
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.
My CODE:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<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>
</configuration>
I've tried installing every other extension for spring and problems still exist...

SpringBoot deployment on Ubuntu with logback configuration fails with FileNotFoundException (Permission Denied)

I am trying to deploy simple SpringBoot application on ubuntu server as an Upstart service.
This application has logback-spring.xml configuration which points to exact same location where the service log files are created i.e. /var/log/upstart directory.
But when I deploy this application it fails with following error indicating some permission issue (Permission Denied),
Exception in thread "main" java.lang.IllegalStateException: Logback configuration error detected:
java.lang.IllegalStateException: Logback configuration error detected:
ERROR in ch.qos.logback.core.rolling.RollingFileAppender[FILE] - openFile(/var/log/upstart/app.log,true) call failed. java.io.FileNotFoundException: /var/log/upstart.app.log (Permission denied)
ERROR in ch.qos.logback.core.rolling.RollingFileAppender[FILE] - openFile(/var/log/upstart/app.log,true) call failed. java.io.FileNotFoundException: /var/log/upstart/app.log (Permission denied)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:153)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:153) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:71)
at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:71) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:49)
at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:49) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:106)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:106) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
at org.springframework.boot.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:262)
at org.springframework.boot.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:262) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
at org.springframework.boot.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:233)
at org.springframework.boot.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:233) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:200)
at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:200) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:176)
at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:176) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:163)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:163) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:136)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:136) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:119)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:119) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.boot.context.event.EventPublishingRunListener.publishEvent(EventPublishingRunListener.java:111)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:65)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
at org.springframework.boot.context.event.EventPublishingRunListener.publishEvent(EventPublishingRunListener.java:111) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
Logback-spring.xml file,
<?xml version="1.0" encoding="UTF-8"?>
<!-- Enable jmxConfiguration to allow dynamic level change through spring boot admin -->
<jmxConfigurator/>
<property resource="log.properties" />
<!-- Standard console appender used in all environments. Upstart catches logs and stores in /var/log/upstart-->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>[%-5level] [%t] %d %logger{35} - %msg%n</pattern>
</encoder>
</appender>
<springProfile name="local">
<appender name="local" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.local.path}/${log.name.async}.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>${log.local.path}/%d{yyyy-MM-dd,aux}/${log.name.async}.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<!-- keep 30 days' worth of history -->
<maxHistory>7</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 256MB -->
<maxFileSize>256MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>%-5level [%t] %d{yyyy-MM-dd_HH:mm:ss.SSS} %logger{35} - %msg%n</Pattern>
</encoder>
</appender>
</springProfile>
<root level="INFO">
<appender-ref ref="console"/>
<appender-ref ref="local"/>
</root>
log.properties file,
log.local.path=/var/log/upstart
log.name.async=propspace-async
Finally I figured out the issue. Though the error was pretty straight forward, there were some things I need to relook into.
The service was owned by user 'appuser' on ubuntu.
The directory (/var/log/upstart/) into which the logs were pointed was not permitted to user 'appuser'. The log directory was owned by user 'root'. Hence I created another directory (/var/log/app/) which is also owned by the same user i.e. 'appuser' and started the application.
It solved the issue.

SpringBoot Logback configuration error - Empty or null pattern

One of my spring boot applications suddenly stopped working, after server restart. The application is failing to start, these are the messages from log file
ERROR o.s.boot.SpringApplication - Application startup failed
java.lang.IllegalStateException: Logback configuration error detected:
ERROR in ch.qos.logback.classic.PatternLayout("") - Empty or null pattern.
Server: WebSphere Application Server
Spring Boot version: 1.5.21.RELEASE
logback-spring.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
<appender name="ROLLING-FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
<file>app.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>app.log.%d{yyyy-MM-dd}.log</fileNamePattern>
</rollingPolicy>
</appender>
<root level="INFO">
<appender-ref ref="ROLLING-FILE"/>
</root>
</configuration>
I tried setting the log parameters in the application properties file but still doesn't work, properties like logging.path, logging.file, logging.pattern.file
The application used to work fine, no code changes were made for last few months, but after server restart it stopped working, application works fine in my local machine.
For people that might still be looking for an answer. We were able to solve this by editing our logback-spring xml by removing:
<include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
and if present (it was in our file but not in the code posted in the question) remove:
<appender-ref ref="CONSOLE"/>

springboot upgrade from 1.2.1 to 1.3.3 logback issue

I have upgraded springboot version from 1.2.1 to 1.3.3 but i am facing some logback problems:
with version 1.2.1 it works perfectly fine:
Exception:
java.lang.IllegalStateException: Logback configuration error detected:
ERROR in ch.qos.logback.core.joran.spi.Interpreter#14:16 - no applicable action for [pattern], current ElementPath is [[configuration][appender][layout][pattern]]
ERROR in ch.qos.logback.core.joran.action.NestedBasicPropertyIA - Unexpected aggregationType AS_BASIC_PROPERTY_COLLECTION
ERROR in ch.qos.logback.core.joran.spi.Interpreter#23:66 - no applicable action for [staticField], current ElementPath is [[configuration][appender][layout][staticField]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter#24:24 - no applicable action for [key], current ElementPath is [[configuration][appender][layout][staticField][key]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter#25:26 - no applicable action for [value], current ElementPath is [[configuration][appender][layout][staticField][value]]
at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:151)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.reinitialize(LogbackLoggingSystem.java:195)
at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:65)
at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:50)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:106)
at org.springframework.boot.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:277)
at org.springframework.boot.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:255)
at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:224)
at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:200)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:166)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:121)
at org.springframework.boot.context.event.EventPublishingRunListener.publishEvent(EventPublishingRunListener.java:111)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:65)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:330)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180)
at com.xx.yy.zz.hh.Application.main(Application.java:14)
Logback.xml:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>BlueBerry %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<appender name="AMQP" class="org.springframework.amqp.rabbit.logback.AmqpAppender">
<!-- <filter class="com.xx.yy.util.LogsFilter" />-->
<layout class="me.moocar.logbackgelf.GelfLayout">
<pattern>BlueBerry %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
<shortMessageLayout class="ch.qos.logback.classic.PatternLayout">
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</shortMessageLayout>
<useLoggerName>true</useLoggerName>
<useThreadName>true</useThreadName>
<useMarker>true</useMarker>
<includeFullMDC>true</includeFullMDC>
<fieldType>requestId:long</fieldType>
<staticField class="me.moocar.logbackgelf.Field">
<key>_facility</key>
<value>GELF</value>
</staticField>
</layout>
<host>srv173.xx.yy.com</host>
<port>XXXX</port>
<username>guest</username>
<password>guest</password>
<exchangeType>direct</exchangeType>
<exchangeName>amq.direct</exchangeName>
<applicationId>RabbitMq-IT-SE</applicationId>
<routingKeyPattern>logs</routingKeyPattern>
<generateId>true</generateId>
<charset>UTF-8</charset>
<durable>true</durable>
<abbreviation>36</abbreviation>
<deliveryMode>NON_PERSISTENT</deliveryMode>
<declareExchange>true</declareExchange>
</appender>
<root level="INFO">
<appender-ref ref="CONSOLE"/>
<!-- <appender-ref ref="GELF TCP APPENDER"/>-->
<appender-ref ref="AMQP"/>
</root>
</configuration>
I tried using Dependencies Management as mentioned in this question but it did not work for me:
spring-boot upgrade from 1.3.2 to 1.3.3: logback issue
Is upgrading to Spring Boot 1.3.4 an option ?
Although not exactly the same symptoms, it still points to logback dependency issues in 1.3.3. It seems to be fixed in 1.3.4: https://github.com/logstash/logstash-logback-encoder/issues/153
Ugrading to Spring Boot 1.3.4 fixed this for me

Springboot sending logs to fluentd not working

I need some help for the following problem.
I have a spring boot application and I would like to configure a fluentd appender using logback.
I've created a file called logback.xml in my src/main/resources with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="true">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%date - %level - [%thread] - %logger - [%file:%line] - %msg%n</pattern>
</encoder>
</appender>
<appender name="FLUENT_TEXT" class="ch.qos.logback.more.appenders.DataFluentAppender">
<tag>dab</tag>
<label>normal</label>
<remoteHost>localhost</remoteHost>
<port>24224</port>
<maxQueueSize>20</maxQueueSize>
</appender>
<logger name="org.com" level="DEBUG"/>
<root level="DEBUG">
<appender-ref ref="STDOUT" />
<appender-ref ref="FLUENT_TEXT" />
</root>
</configuration>
In my build.gradle I have :
compile 'org.fluentd:fluent-logger:0.3.1'
compile 'com.sndyuk:logback-more-appenders:1.1.0'
When I launch the app using gradle bootRun I have the following message:
10:56:33,020 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - Attempted to append to non started appender [STDOUT].
10:56:33,020 |-WARN in ch.qos.logback.more.appenders.DataFluentAppender[FLUENT_TEXT] - Attempted to append to non started appender [FLUENT_TEXT].
10:56:33,028 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - Attempted to append to non started appender [STDOUT].
Exception in thread "main" 10:56:33,028 |-WARN in ch.qos.logback.more.appenders.DataFluentAppender[FLUENT_TEXT] - Attempted to append to non started appender [FLUENT_TEXT].
java.lang.NullPointerException
at ch.qos.logback.more.appenders.DataFluentAppender$FluentDaemonAppender.close(DataFluentAppender.java:72)
I've found here https://github.com/spring-projects/spring-boot/blob/master/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc something saying that logback.xml is loaded too early so I need to use a file called logback-spring.xml.
I've did it and it's like the file is never loaded, no error but nothing gets to my fluetd socket.
Any idea how to solve it ?
Thanks.
C.C.
When running your springboot application, load a 'spring' profile.
One way of doing it would be via the command line, see below.
-Dspring.profiles.active=spring

Resources