我正在尝试在上部署简单的springboot应用程序 ubuntu
服务器作为 Upstart
服务。此应用程序具有 logback-spring.xml
指向创建服务日志文件的完全相同位置的配置,即。 /var/log/upstart
目录。
但当我部署这个应用程序时,它失败了,并出现以下错误,表明存在权限问题( Permission Denied
),
线程“main”java.lang.illegalstateexception中出现异常:检测到logback配置错误:java.lang.illegalstateexception:检测到logback配置错误:ch.qos.logback.core.rolling.rollingfileappender[file]中出现错误-openfile(/var/log/upstart/app.log,true)调用失败。java.io.filenotfoundexception:/var/log/upstart.app.log(权限被拒绝)ch.qos.logback.core.rolling.rollingfileappender[file]中的错误-openfile(/var/log/upstart/app.log,true)调用失败。java.io.filenotfoundexception:/var/log/upstart/app.log(权限被拒绝),位于org.springframework.boot.logging.logback.logbackloggingsystem.loadconfiguration(logbackloggingsystem)。java:153)在org.springframework.boot.logging.logback.logbackloggingsystem.loadconfiguration(logbackloggingsystem。java:153) ~[spring-boot-1.3.1.发布。jar:1.3.1.release]在org.springframework.boot.logging.abstractloggingsystem.initializewithconventions(abstractloggingsystem。java:71)在org.springframework.boot.logging.abstractloggingsystem.initializewithconventions(abstractloggingsystem。java:71)~[spring-boot-1.3.1.发布。jar:1.3.1.release]在org.springframework.boot.logging.abstractloggingsystem.initialize(abstractloggingsystem。java:49)在org.springframework.boot.logging.abstractloggingsystem.initialize(abstractloggingsystem。java:49)~[spring-boot-1.3.1.发布。jar:1.3.1.release]在org.springframework.boot.logging.logback.logbackloggingsystem.initialize(logbackloggingsystem。java:106)在org.springframework.boot.logging.logback.logbackloggingsystem.initialize(logbackloggingsystem。java:106)~[spring-boot-1.3.1.发布。jar:1.3.1.release]在org.springframework.boot.logging.loggingapplicationlistener.initializesystem(loggingapplicationlistener。java:262)在org.springframework.boot.logging.loggingapplicationlistener.initializesystem(loggingapplicationlistener。java:262)~[spring-boot-1.3.1.发布。jar:1.3.1.release]在org.springframework.boot.logging.loggingapplicationlistener.initialize(loggingapplicationlistener。java:233)在org.springframework.boot.logging.loggingapplicationlistener.initialize(loggingapplicationlistener。java:233)~[spring-boot-1.3.1.发布。jar:1.3.1.release]在org.springframework.boot.logging.loggingapplicationlistener.onapplicationenvironmentpreparedevent(loggingapplicationlistener)。java:200)在org.springframework.boot.logging.loggingapplicationlistener.onapplicationenvironmentpreparedevent(loggingapplicationlistener。java:200)~[spring-boot-1.3.1.发布。jar:1.3.1.release]在org.springframework.boot.logging.loggingapplicationlistener.onapplicationevent(loggingapplicationlistener。java:176)在org.springframework.boot.logging.loggingapplicationlistener.onapplicationevent(loggingapplicationlistener。java:176)~[spring-boot-1.3.1.发布。jar:1.3.1.release]在org.springframework.context.event.simpleapplicationeventmulticaster.invokelistener(simpleapplicationeventmulticaster。java:163)位于org.springframework.context.event.simpleapplicationeventmulticaster.invokelistener(simpleapplicationeventmulticaster。java:163)~[spring-context-4.2.4.发布。jar:4.2.4.release]在org.springframework.context.event.simpleapplicationeventmulticaster.multicastevent(simpleapplicationeventmulticaster。java:136)位于org.springframework.context.event.simpleapplicationeventmulticaster.multicastevent(simpleapplicationeventmulticaster)。java:136)~[spring-context-4.2.4.发布。jar:4.2.4.release]在org.springframework.context.event.simpleapplicationeventmulticaster.multicastevent(simpleapplicationeventmulticaster。java:119)位于org.springframework.context.event.simpleapplicationeventmulticaster.multicastevent(simpleapplicationeventmulticaster)。java:119)~[spring-context-4.2.4.发布。jar:4.2.4.release]在org.springframework.boot.context.event.eventpublishingrunlistener.publishevent(eventpublishingrunlistener)。java:111)位于org.springframework.boot.context.event.eventpublishingrunlistener.environmentprepared(eventpublishingrunlistener)。java:65)在org.springframework.boot.springapplicationrunlisteners.environmentprepared(springapplicationrunlisteners)。java:54)位于org.springframework.boot.context.event.eventpublishingrunlistener.publishevent(eventpublishingrunlistener)。java:111)~[spring-boot-1.3.1.发布。jar:1.3.1.release]
logback-spring.xml文件,
<?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文件,
log.local.path=/var/log/upstart
log.name.async=propspace-async
1条答案
按热度按时间qyuhtwio1#
我终于弄明白了问题所在。虽然这个错误很直接,但有些事情我需要重新考虑。
这个
service
是owned
按用户'appuser'
在ubuntu上。目录(
/var/log/upstart/
)不允许将日志指向的appuser
'. 日志目录属于用户的root
'. 因此,我创建了另一个目录(/var/log/app/
)它也属于同一个用户,即“appuser”,并启动了应用程序。它解决了这个问题。