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

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.

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...

Log_path_is_undefined and log_file_is_undefined

I'm updating Spring boot version from 2.5 to 2.6 and I encounter an issue with Logback.
Here's the snippet of my application.properties file:
logging.file=abc.log
logging.path=.
And a part of my logback-spring.xml
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_PATH:-.}/${LOG_FILE}.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>${LOG_PATH:-.}/${LOG_FILE}-%i.log</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>3</maxIndex>
</rollingPolicy>
<!-- Only allow a file to get to ~10MB -->
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>10MB</maxFileSize>
</triggeringPolicy>
<encoder>
<pattern>%date{ISO8601} %-5level [%-35.35logger{30}] %msg%n</pattern>
</encoder>
</appender>
I'm getting the error:
2022-10-07 22:51:08,903 INFO [o.h.v.internal.util.Version ] HV000001: Hibernate Validator 6.0.22.Final
2022-10-07 22:51:09,241 INFO [o.s.c.a.ConfigurationClassParser ] Properties location [classpath:application.properties] not resolvable: class path resource [application.properties] cannot be opened because it does not exist
2022-10-07 22:51:10,158 WARN [.AnnotationConfigApplicationContext] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException:
I also get a file named: log_file_is_undefined.log
What am I missing?
From the documentation:
${LOG_FILE}: Whether logging.file.name was set in Boot’s external configuration.
${LOG_PATH}: Whether logging.file.path (representing a directory for log files to live in) was set in Boot’s external configuration.
So use:
logging.file.name=abc.log
logging.file.path=.

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

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.

spring-boot-logger.log file location for deployed spring boot app

I followed this tutorial to setup spring boot logging in my app and it work correctly in my development environment but not after I deploy the app.
The spring app log files should go to ${CATALINA_BASE}/logs/spring-boot-logger.log when app is deployed. How do I configure that?
My logback-spring.xml:
<property name="LOGS" value="./logs" />
<appender name="Console"
class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%black(%d{ISO8601}) %highlight(%-5level) [%blue(%t)] %yellow(%C{1.}): %msg%n%throwable
</Pattern>
</layout>
</appender>
<appender name="RollingFile"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOGS}/spring-boot-logger.log</file>
<encoder
class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>%d %p %C{1.} [%t] %m%n</Pattern>
</encoder>
<rollingPolicy
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- rollover daily and when the file reaches 10 MegaBytes -->
<fileNamePattern>${LOGS}/archived/spring-boot-logger-%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>10MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
</appender>
<!-- LOG everything at INFO level -->
<root level="info">
<appender-ref ref="RollingFile" />
<appender-ref ref="Console" />
</root>
<!-- LOG "com.baeldung*" at TRACE level -->
<logger name="xxx.app" level="trace" additivity="false">
<appender-ref ref="RollingFile" />
<appender-ref ref="Console" />
</logger>
When I start the app on the deployment server using this configuration I get:
java.lang.IllegalStateException: Logback configuration error detected:
ERROR in ch.qos.logback.core.rolling.RollingFileAppender[RollingFile] - Failed to create parent directories for [/./logs/spring-boot-logger.log]
ERROR in ch.qos.logback.core.rolling.RollingFileAppender[RollingFile] - openFile(./logs/spring-boot-logger.log,true) call failed. java.io.FileNotFoundException: ./logs/spring-
boot-logger.log (No such file or directory)
I also tried configuring logging.file.name = ${catalina.base}/logs/${service.name}.log in application.properties like suggested here but then I receive an error when running mvn clean install locally
[ERROR] contextLoads Time elapsed: 0.004 s <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'catalina.base' in value "${catalina.base}/logs/${service.name}.log"
You want to write your log file to the ${CATALINA_BASE}/logs directory, but you used ./logs in your configuration file. This would of course work if the working directory of your Tomcat server were ${CATALINA_BASE}, but it is unsafe to assume anything about the working directory of the Tomcat server (and in your case it's not ${CATALINA_BASE}).
Use variable substitution in your logback-spring.xml file:
<property name="LOGS" value="${catalina.base:-.}/logs" />
The default value . will be used when there is no catalina.base property (i.e. when you use the embedded Tomcat).

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

Resources