简体   繁体   English

如何设置Spring Cloud配置的日志记录级别

[英]How to set logging level for spring cloud config

I am trying to debug some issues I'm having with my spring cloud configuration, but I'm not sure how to correctly set the logging level for it. 我正在尝试调试我的Spring Cloud配置遇到的一些问题,但是我不确定如何正确地为其设置日志记录级别。 I have tried setting the logging level "org.springframework.cloud to trace, but that doesn't seem to have any effect. What is the correct package for logging spring cloud? 我尝试将日志记录级别"org.springframework.cloud设置为可跟踪,但这似乎没有任何效果。用于记录Spring Cloud的正确软件包是什么?

Update I'm hoping to see basic information like if properties were found. 更新我希望看到诸如找到属性之类的基本信息。

Update2 The issue turned out to be related to my JBoss appender. Update2问题原来与我的JBoss附加程序有关。 I was setting the log level of the correct package, but the logging level of the console appender was set to info, so none of the cloud config info was being logged. 我正在设置正确软件包的日志级别,但是控制台附加程序的日志级别设置为info,因此没有任何云配置信息被记录。

Example using .yml file: 使用.yml文件的示例:

logging:
  level:
    ROOT: INFO
    org.springframework.cloud.config: DEBUG

By the way, if you are debugging from the client, there isn't a ton of code: https://github.com/spring-cloud/spring-cloud-config/tree/master/spring-cloud-config-client/src/main/java/org/springframework/cloud/config 顺便说一句,如果您正在从客户端进行调试,则没有很多代码: https : //github.com/spring-cloud/spring-cloud-config/tree/master/spring-cloud-config-client / src目录/主/ JAVA /组织/ springframework的/云/配置

So, whatever you are hoping for may be in a different package. 因此,无论您希望什么,都可以使用其他包装。

We have to set the Log configuration details in .yml file as shown below 我们必须在.yml文件中设置日志配置详细信息,如下所示

logging:
  file: D:/PathToLogFile/configuration-server.log
  level:
    ROOT: 'INFO'
  config: classpath:logback-springtest.xml

Here is complete logback-springtest.xml defination. 这是完整的logback-springtest.xml定义。

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOG_FILE}</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${LOG_FILE}-%d{yyyy-MM-dd}.%i.zip</fileNamePattern>
            <maxHistory>30</maxHistory>
            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                <maxFileSize>50MB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
        </rollingPolicy>
        <encoder>
            <pattern>%date{YYYY-MM-dd HH:mm:ss} %level [%thread] %logger{10} %msg%n</pattern>
        </encoder>
    </appender>

    <logger name="org.springframework" level="INFO">
        <appender-ref ref="FILE"/>
    </logger>

    <logger name="org.apache" level="INFO">
        <appender-ref ref="FILE"/>
    </logger>
</configuration>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM