全部博文(150)
分类: Java
2017-04-11 10:28:45
前几日开发同事请求在jenkins服务器创建几个日志目录,解释说因为没有相关日志目录导致构建失败,检查构建日志发现如下错误:
Logging system failed to initialize using configuration from 'classpath:logback.xml' java.lang.IllegalStateException: Logback configuration error detected: ERROR in ch.qos.logback.core.rolling.RollingFileAppender[FILE] - Failed to create parent directories for [/logs/a6/a6-ss-discovery/spring.log] ERROR in ch.qos.logback.core.rolling.RollingFileAppender[FILE] - openFile(/logs/a6/a6-ss-discovery/spring.log,true) call failed. java.io.FileNotFoundException: /logs/a6/a6-ss-discovery/spring.log (No such file or directory)
从运维角度出发,把日志放到/目录是个稳定性的隐患,所以必须解决,反馈开发同事修改,开发同事是在太忙了,答应以后修改。于是有了本文。
如果bin下有多个可运行app,那么logs下面创建appname的二级目录
示例
logs └── a6-ss-discovery ├── error.log ├── spring.log └── system.log
name字段值修改实际名称
spring: application: name: a6-ss-discovery
path字段值修改为相对路径logs
# Logging logging: config: classpath:logback.xml path: ../logs/${spring.application.name}
...... [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 20.344s [INFO] Finished at: Mon Apr 10 18:51:36 CST 2017 [INFO] Final Memory: 35M/428M [INFO] ------------------------------------------------------------------------