简体   繁体   English

spring 中的 logback.xml 启动不打印调试消息

[英]logback.xml in spring boot not printing debug messages

New to logback. logback 的新手。 I'm trying to print debug and info messages to external file.我正在尝试将调试和信息消息打印到外部文件。

I'm reading the configuration from this file我正在从这个文件中读取配置

logback.xml logback.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

    <property name="HOME_LOG" value="C:\\Users\\Usuario\\Desktop\\SH_DashboardCES\\Logs\\Dashboard.log"/>

    <appender name="FILE-ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${HOME_LOG}</file>

        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <fileNamePattern>logs/archived/app.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
            <!-- each archived file, size max 10MB -->
            <maxFileSize>10MB</maxFileSize>
            <!-- total size of all archive files, if total size > 20GB, it will delete old archived file -->
            <totalSizeCap>20GB</totalSizeCap>
            <!-- 60 days to keep -->
            <maxHistory>60</maxHistory>
        </rollingPolicy>

        <encoder>
            <pattern>%d %p %c{1.} [%t] %m%n</pattern>
        </encoder>
    </appender>

    <logger name="pe.com.dashboard" level="DEBUG" additivity="false">
        <appender-ref ref="FILE-ROLLING"/>
    </logger>

    <root level="ERROR">
        <appender-ref ref="FILE-ROLLING"/>
    </root>

</configuration>

Printed Dashboard.log打印的 Dashboard.log

2020-04-06 16:18:37,362 INFO pe.com.claro.postventa.dashboard.Application [main] Starting Application v1.0.0 on HPERLAPVALDK with PID 17808 (C:\Users\Usuario\Desktop\SH_DashboardCES\Dashboard-1.0.0.jar started by valdezkj in C:\Users\Usuario\Desktop\SH_DashboardCES)
2020-04-06 16:18:37,365 DEBUG pe.com.claro.postventa.dashboard.Application [main] Running with Spring Boot v2.2.5.RELEASE, Spring v5.2.4.RELEASE
2020-04-06 16:18:37,365 INFO pe.com.claro.postventa.dashboard.Application [main] No active profile set, falling back to default profiles: default
2020-04-06 16:18:52,651 INFO pe.com.claro.postventa.dashboard.Application [main] Started Application in 15.828 seconds (JVM running for 16.296)

Java Class implementing logback Java Class 实现 logback

package pe.com.dashboard.dao;

    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;

    import javax.sql.DataSource;
    import java.util.*;

    @Repository
    public class ClarifyDaoImpl implements ClarifyDao {

        Logger logger = LoggerFactory.getLogger(ClarifyDaoImpl.class);


        @Override
        public ConsultaTipificacionOutputMapper consultaTipificacion(ConsultaTipificacionInputMapper request) throws DBException {
            logger.info(INICIO_TRANSACCION + nombreMetodo);

            logger.debug(INPUT_PARAMETERS + request.toString());

            return null;
        }
    }

None of the messages in the java class is printed even when the log level of the package is set to DEBUG.即使将 package 的日志级别设置为 DEBUG,也不会打印 java class 中的任何消息。

<root level="ERROR">
        <appender-ref ref="FILE-ROLLING"/>
</root>

log level : trace < debug < info < warn < Error日志级别:trace < debug < info < warn < Error

you can change level to debug您可以将级别更改为调试

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

相关问题 Spring boot logback.xml 外化 - Spring boot logback.xml externalisation 在不使用 logback.xml 文件的情况下,在 spring boot 中使用 MDC 或任何过滤器屏蔽日志消息中的密码 - Mask the passwords in log messages using MDC or Any Filters in spring boot without using logback.xml file spring-boot logback.xml属性,具体取决于配置文件 - spring-boot logback.xml property depending on profile 使用Apache CXF的Spring Boot不使用logback.xml - Spring boot with apache cxf not using logback.xml Spring Boot logback.xml 创建 .tmp 文件 - Spring Boot logback.xml creating .tmp Files Spring Boot Logback记录DEBUG消息 - Spring Boot Logback logging DEBUG messages Spring Boot:如何根据当前环境或spring配置文件使用自定义logback.xml - Spring Boot: How to use custom logback.xml depending on current environment or spring profile 如何将 spring 引导应用程序指向外部 jar 的 logback.xml - how to point spring boot application to external jar's logback.xml 如何在 Spring Boot 中将父项目的 gradle 属性传递给 logback.xml? - How to pass gradle property of parent project to logback.xml in Spring Boot? 如何在 spring 启动应用程序中通过 logback.xml 为两个附加程序设置两个不同的日志级别? - How to set up two different log levels for two appenders via logback.xml in spring boot app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM