- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经根据 Spring Boot Documentation 配置了我的 logback-spring.xml .这是我的 logback-spring.xml 文件
<configuration>
<springProperty name="appName" source="spring.application.name" defaultValue="myLogFile" />
<property name="log.date" value="%d{yyyy-MM-dd}" />
<property name="log.path" value="/log" />
<property name="log.file" value="${appName}" />
<property name="log.live.path" value="${log.path}/${log.file}.log" />
<appender name="myLogAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.live.path}</file>
<append>true</append>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.path}/archive/${log.file}.${log.date}.log.gz</fileNamePattern>
<maxHistory>1</maxHistory>
</rollingPolicy>
</appender>
<logger name="com.log.logback" level="INFO" />
<logger name="com.log.sample" level="INFO" />
<root level="ERROR">
<appender-ref ref="myLogAppender" />
</root>
</configuration>
应用程序属性
spring.application.name=mybootapp
当我启动我的 spring boot 应用程序时,我看到在 /log
下创建了 2 个目录路径是 myLogFile
和 bootstrap
.从日志中,我可以看到在 logback 可以访问 spring 属性之前创建了 bootstrap 目录。我不知道为什么要创建 bootstrap 目录。我在使用 <springProperty>
之前没有看到这个问题在 logback xml 中。我在这里缺少任何配置吗?我在网上找不到任何相关信息。
供引用的 Logback 日志。
15:54:02,085 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@610f7aa - URL [jar:file:/C:/projects/jars/logback-logging-17.2.2.INT.jar!/logback-spring.xml] is not of type file
15:54:02,132 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Will scan for changes in [jar:file:/C:/projects/jars/logback-logging-17.2.2.INT.jar!/logback-spring.xml]
15:54:02,132 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Setting ReconfigureOnChangeTask scanning period to 5 minutes
15:54:02,132 |-WARN in Logger[org.springframework.core.env.PropertySourcesPropertyResolver] - No appenders present in context [default] for logger [org.springframework.core.env.PropertySourcesPropertyResolver].
15:54:02,274 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
15:54:02,274 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [myLogAppender]
15:54:02,305 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@867988177 - Will use gz compression
15:54:02,305 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@867988177 - Will use the pattern /log/archive/bootstrap.%d{yyyy-MM-dd}.log for the active file
15:54:02,305 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - The date pattern is 'yyyy-MM-dd' from file name pattern '/log/archive/bootstrap.%d{yyyy-MM-dd}.log.gz'.
15:54:02,305 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Roll-over at midnight.
15:54:02,305 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Setting initial period to Tue Apr 18 15:45:05 EDT 2017
15:54:02,320 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[myLogAppender] - Active log file name: /log/bootstrap.log
15:54:02,320 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[myLogAppender] - File property is set to [/log/bootstrap.log]
15:54:02,336 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.log.logback] to INFO
15:54:02,336 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@48e1f6c7 - Propagating INFO level on Logger[com.log.logback] onto the JUL framework
15:54:02,336 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.log.sample] to INFO
15:54:02,336 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@48e1f6c7 - Propagating INFO level on Logger[com.log.sample] onto the JUL framework
15:54:02,336 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to ERROR
15:54:02,336 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@48e1f6c7 - Propagating ERROR level on Logger[ROOT] onto the JUL framework
15:54:02,336 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [myLogAppender] to Logger[ROOT]
15:54:02,336 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
15:54:02,336 |-INFO in org.springframework.boot.logging.logback.SpringBootJoranConfigurator@26abb146 - Registering current configuration as safe fallback point
15:54:03,139 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@242aa8d9 - URL [jar:file:/C:/projects/jars/logback-logging-17.2.2.INT.jar!/logback-spring.xml] is not of type file
15:54:03,139 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Will scan for changes in [jar:file:/C:/projects/jars/logback-logging-17.2.2.INT.jar!/logback-spring.xml]
15:54:03,139 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Setting ReconfigureOnChangeTask scanning period to 5 minutes
15:54:03,139 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
15:54:03,139 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [myLogAppender]
15:54:03,139 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@300604602 - Will use gz compression
15:54:03,139 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@300604602 - Will use the pattern /log/archive/mybootapp.%d{yyyy-MM-dd}.log for the active file
15:54:03,140 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - The date pattern is 'yyyy-MM-dd' from file name pattern '/log/archive/mybootapp.%d{yyyy-MM-dd}.log.gz'.
15:54:03,140 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Roll-over at midnight.
15:54:03,140 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Setting initial period to Tue Apr 18 15:53:03 EDT 2017
15:54:03,140 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[myLogAppender] - Active log file name: /log/mybootapp.log
15:54:03,140 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[myLogAppender] - File property is set to [/log/mybootapp.log]
15:54:03,140 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.log.logback] to INFO
15:54:03,140 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@1b065145 - Propagating INFO level on Logger[com.log.logback] onto the JUL framework
15:54:03,140 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.log.sample] to INFO
15:54:03,140 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@1b065145 - Propagating INFO level on Logger[com.log.sample] onto the JUL framework
15:54:03,140 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to ERROR
15:54:03,140 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@1b065145 - Propagating ERROR level on Logger[ROOT] onto the JUL framework
15:54:03,140 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [myLogAppender] to Logger[ROOT]
15:54:03,140 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
15:54:03,140 |-INFO in org.springframework.boot.logging.logback.SpringBootJoranConfigurator@45cff11c - Registering current configuration as safe fallback point
有人可以帮忙吗。
最佳答案
这可能是因为我刚刚更新到 1.5.18 但这似乎有效,我与你的唯一变化是添加了 scope="context"
。这是我使用 GELF appender 完成的方法
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="true">
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<springProperty scope="context" name="name" source="spring.application.name"/>
<appender name="gelf" class="de.appelgriepsch.logback.GelfAppender">
<server>192.168.1.113</server>
<includeSource>true</includeSource>
<includeMDC>true</includeMDC>
<includeLevelName>true</includeLevelName>
<additionalFields>name=${name}</additionalFields>
</appender>
<root>
<appender-ref ref="gelf"/>
</root>
</configuration>
关于带有 Logback + springProperty 的 Spring Boot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43482050/
我已经根据 Spring Boot Documentation 配置了我的 logback-spring.xml .这是我的 logback-spring.xml 文件
我使用 SpringBoot 2.1 以及 spring-boot-maven-plugin 和 git-commit-id-plugin 自动使用构建填充执行器信息端点信息。效果很好。我将值分组在
我使用 SpringBoot 2.1 以及 spring-boot-maven-plugin 和 git-commit-id-plugin 自动使用构建填充执行器信息端点信息。效果很好。我将值分组在
我正在通过 spring-cloud Brixton.M2 使用 Spring Boot 1.3.0.RC1,并且无法将 spring boot 属性拉入 logback.xml,正如此功能 ch
我在应用程序中有一个 logback-spring.xml 文件,并且我正在使用 springProperties,如下例所示 我的 springProperties 的值在 spring cl
我是一名优秀的程序员,十分优秀!