JHipster - Log Files

前端 未结 6 1304
借酒劲吻你
借酒劲吻你 2021-02-06 04:50

I have a JHipster application running and I would like to know where are the logs files. Where are they generated ? (It\'s a newbie question, but can\'t find anything)

I

相关标签:
6条回答
  • 2021-02-06 05:12

    I was facing the same issue, but after making lot of changes log files are getting changed , but log messages are not inserted in the log file.

    I made the following changes to logback-spring.xml

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

    <!--<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <charset>utf-8</charset>
            <Pattern>[%p] %c - %m%n</Pattern>
        </encoder>
    </appender>-->
    
    <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>logFile.%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>90</maxHistory>
        </rollingPolicy>
        <encoder>
            <charset>utf-8</charset>
            <Pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n</Pattern>
        </encoder>
    </appender>
    
    <appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
        <queueSize>512</queueSize>
        <appender-ref ref="FILE"/>
    </appender>
    
    <logger name="com.myolo" level="INFO"/>
    <logger name="com.myolo" level="DEBUG"/>
    <logger name="com.myolo" level="ERROR"/>
    <logger name="javax.activation" level="WARN"/>
    <logger name="javax.mail" level="WARN"/>
    <logger name="javax.xml.bind" level="WARN"/>
    <logger name="ch.qos.logback" level="WARN"/>
    <logger name="com.codahale.metrics" level="WARN"/>
    <logger name="com.ryantenney" level="WARN"/>
    <logger name="com.sun.xml.internal.bind" level="WARN"/>
    <logger name="com.zaxxer" level="WARN"/>
    <logger name="io.undertow" level="WARN"/>
    <logger name="net.sf.ehcache" level="WARN"/>
    <logger name="org.apache" level="WARN"/>
    <logger name="org.apache.catalina.startup.DigesterFactory" level="OFF"/>
    <logger name="org.bson" level="WARN"/>
    <logger name="org.hibernate.validator" level="WARN"/>
    <logger name="org.hibernate" level="WARN"/>
    <logger name="org.hibernate.ejb.HibernatePersistence" level="OFF"/>
    <logger name="org.springframework" level="WARN"/>
    <logger name="org.springframework.web" level="WARN"/>
    <logger name="org.springframework.security" level="WARN"/>
    <logger name="org.springframework.cache" level="WARN"/>
    <logger name="org.thymeleaf" level="WARN"/>
    <logger name="org.xnio" level="WARN"/>
    <logger name="springfox" level="WARN"/>
    <logger name="sun.rmi" level="WARN"/>
    <logger name="liquibase" level="WARN"/>
    <logger name="sun.rmi.transport" level="WARN"/>
    
    <contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
        <resetJUL>true</resetJUL>
    </contextListener>
    
    <root level="debug">
        <appender-ref ref="FILE"/>
    </root>
    
    <logger name="com.myolo">
        <appender-ref ref="FILE" />
    </logger>
    

    0 讨论(0)
  • 2021-02-06 05:13

    The src/main/resources/logback.xml file contains the JHipster logging configuration. For reference, there is an additional src/test/resources/logback-test.xml file that is used when running the unit tests.

    By default, JHipster logs only to the console. When running using the mvn spring-boot:run or gradlew bootRun (the default build targets), the only place your logs will appear is in the console window. However, if running inside a web container such as Tomcat, the web container might automatically save the logs to a container-specific location. For example, Tomcat saves all log messages printed to the console to [CATALINA_HOME]/logs/catalina.out.

    If you wish to reconfigure your application to print logs to a file, you can do so by uncommenting and customizing the FILE appender declaration in the logback configuration file mentioned above and then adding a reference to the FILE appender to the root logger. Example:

    ...
    
    <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>logFile.%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>90</maxHistory>
        </rollingPolicy>
        <encoder>
            <charset>utf-8</charset>
            <Pattern>%d %-5level [%thread] %logger{0}: %msg%n</Pattern>
        </encoder>
    </appender>
    
    ...
    
    <root level="${logback.loglevel}">
        <appender-ref ref="CONSOLE"/> <!-- Optionally remove this -->
        <appender-ref ref="FILE"/> <!-- Add this -->
    </root>
    
    ...
    
    0 讨论(0)
  • 2021-02-06 05:14

    The default jh configuration src\main\resourcess\logback-spring.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    
    <configuration scan="true">
        <include resource="org/springframework/boot/logging/logback/base.xml"/>
    
    <!-- The FILE and ASYNC appenders are here as examples for a production configuration -->
    <!--
        <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
            <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
                <fileNamePattern>logFile.%d{yyyy-MM-dd}.log</fileNamePattern>
                <maxHistory>90</maxHistory>
            </rollingPolicy>
            <encoder>
                <charset>utf-8</charset>
                <Pattern>%d %-5level [%thread] %logger{0}: %msg%n</Pattern>
            </encoder>
        </appender>
    
        <appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
            <queueSize>512</queueSize>
            <appender-ref ref="FILE"/>
        </appender>
    -->
    
        <logger name="com.theice.asdlc" level="#logback.loglevel#"/>
    
        <logger name="javax.activation" level="WARN"/>
        <logger name="javax.mail" level="WARN"/>
        <logger name="javax.xml.bind" level="WARN"/>
        <logger name="ch.qos.logback" level="WARN"/>
        <logger name="com.codahale.metrics" level="WARN"/>
        <logger name="com.ryantenney" level="WARN"/>
        <logger name="com.sun" level="WARN"/>
        <logger name="com.zaxxer" level="WARN"/>
        <logger name="org.apache" level="WARN"/>
        <logger name="org.apache.catalina.startup.DigesterFactory" level="OFF"/>
        <logger name="org.bson" level="WARN"/>
        <logger name="org.hibernate.validator" level="WARN"/>
        <logger name="org.hibernate" level="WARN"/>
        <logger name="org.hibernate.ejb.HibernatePersistence" level="OFF"/>
        <logger name="org.springframework" level="WARN"/>
        <logger name="org.springframework.web" level="WARN"/>
        <logger name="org.springframework.security" level="WARN"/>
        <logger name="org.springframework.cache" level="WARN"/>
        <logger name="org.thymeleaf" level="WARN"/>
        <logger name="org.xnio" level="WARN"/>
        <logger name="springfox" level="WARN"/>
        <logger name="sun.rmi" level="WARN"/>
        <logger name="liquibase" level="WARN"/>
        <logger name="sun.rmi.transport" level="WARN"/>
    
        <contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
            <resetJUL>true</resetJUL>
        </contextListener>
    
        <root level="#logback.loglevel#">
            <appender-ref ref="CONSOLE"/>
        </root>
    
    </configuration> 

    includes spring-boot-master\spring-boot\src\main\resources\org\springframework\boot\logging\logback\base.xml

    <?xml version="1.0" encoding="UTF-8"?>
    
    <!--
    Base logback configuration provided for compatibility with Spring Boot 1.1
    -->
    
    <included>
    	<include resource="org/springframework/boot/logging/logback/defaults.xml" />
    	<property name="LOG_FILE" value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}/}spring.log}"/>
    	<include resource="org/springframework/boot/logging/logback/console-appender.xml" />
    	<include resource="org/springframework/boot/logging/logback/file-appender.xml" />
    	<root level="INFO">
    		<appender-ref ref="CONSOLE" />
    		<appender-ref ref="FILE" />
    	</root>
    </included>
    which includes defaults.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    
    <!--
    Default logback configuration provided for import, equivalent to the programmatic
    initialization performed by Boot
    -->
    
    <included>
    	<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
    	<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
    	<conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
    
    	<property name="CONSOLE_LOG_PATTERN" value="%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/>
    	<property name="FILE_LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} ${LOG_LEVEL_PATTERN:-%5p} ${PID:- } --- [%t] %-40.40logger{39} : %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/>
    
    	<appender name="DEBUG_LEVEL_REMAPPER" class="org.springframework.boot.logging.logback.LevelRemappingAppender">
    		<destinationLogger>org.springframework.boot</destinationLogger>
    	</appender>
    
    	<logger name="org.apache.catalina.startup.DigesterFactory" level="ERROR"/>
    	<logger name="org.apache.catalina.util.LifecycleBase" level="ERROR"/>
    	<logger name="org.apache.coyote.http11.Http11NioProtocol" level="WARN"/>
    	<logger name="org.apache.sshd.common.util.SecurityUtils" level="WARN"/>
    	<logger name="org.apache.tomcat.util.net.NioSelectorPool" level="WARN"/>
    	<logger name="org.crsh.plugin" level="WARN"/>
    	<logger name="org.crsh.ssh" level="WARN"/>
    	<logger name="org.eclipse.jetty.util.component.AbstractLifeCycle" level="ERROR"/>
    	<logger name="org.hibernate.validator.internal.util.Version" level="WARN"/>
    	<logger name="org.springframework.boot.actuate.autoconfigure.CrshAutoConfiguration" level="WARN"/>
    	<logger name="org.springframework.boot.actuate.endpoint.jmx" additivity="false">
    		<appender-ref ref="DEBUG_LEVEL_REMAPPER"/>
    	</logger>
    	<logger name="org.thymeleaf" additivity="false">
    		<appender-ref ref="DEBUG_LEVEL_REMAPPER"/>
    	</logger>
    </included>

    console-appender.xml

    <?xml version="1.0" encoding="UTF-8"?>
    
    <!--
    Console appender logback configuration provided for import, equivalent to the programmatic
    initialization performed by Boot
    -->
    
    <included>
    	<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
    		<encoder>
    			<pattern>${CONSOLE_LOG_PATTERN}</pattern>
    			<charset>utf8</charset>
    		</encoder>
    	</appender>
    </included>

    and finally file-appender.xml

    <?xml version="1.0" encoding="UTF-8"?>
    
    <!--
    File appender logback configuration provided for import, equivalent to the programmatic
    initialization performed by Boot
    -->
    
    <included>
    	<appender name="FILE"
    		class="ch.qos.logback.core.rolling.RollingFileAppender">
    		<encoder>
    			<pattern>${FILE_LOG_PATTERN}</pattern>
    		</encoder>
    		<file>${LOG_FILE}</file>
    		<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
    			<fileNamePattern>${LOG_FILE}.%i</fileNamePattern>
    		</rollingPolicy>
    		<triggeringPolicy
    			class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
    			<MaxFileSize>10MB</MaxFileSize>
    		</triggeringPolicy>
    	</appender>
    </included>

    which is creating a spring.log file in the temp directory that rolls every 10MB.

    Here is a version that may be more appropriate for production.

    It enables the async file appender, and replaces the temp directory spring.log with debug, info (without trace or debug), and error (without info,trace,debug) log files in the catalina_base directory that roll each day.

    It uses an easily-parsed splunk format, and column widths that are easy for humans to scan.

    It includes columns that a simple Servlet Filter can use to add values to MDC for: IP=IP Address, S=Session Id, TX=Transaction Id, U=User Id. eg org.slf4j.MDC.put("TX", java.util.UUID.randomUUID().toString()); :

    <?xml version="1.0" encoding="UTF-8"?>
    
    <configuration scan="true">
    	<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
    	<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
    	<conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
    
      
      <!-- Write logs to Tomcat instance logs directory or current directory -->
    	<property name="LOG_ROOT"            value="${CATALINA_BASE:-.}"/>
    	<property name="LOG_PATH"            value="${LOG_ROOT}/logs"/>
    	<property name="LOG_ARCHIVE_PREFIX"  value="${LOG_PATH}/APPID-%d{yyyy-MM-dd}-"/>
    	<property name="LOG_ARCHIVE_DAYS"    value="5"/>
      
      <!-- Patterns assume Servlet Filter adds values to MDC for: IP=IP Address, S=Session Id, TX=Transaction Id, U=User Id.  eg org.slf4j.MDC.put("TX", java.util.UUID.randomUUID().toString());  -->
    	<property name="LOG_PATTERN"         value="%date{HH:mm:ss.SSS} ,ip=%-16.16X{IP} ,s=%-32.32X{S} ,x=%-30.30X{TX} ,l=%-5.5level ,u=%-12.12X{U} ,c=%-30.30logger{0} ,f=%-20.20method ,t=%-15.15t ,m=%-80m ,cf=%logger %n"/>  
      <property name="CONSOLE_LOG_PATTERN" value="%date{HH:mm:ss.SSS} ,ip=%-3.3X{IP} ,s=%-8.8X{S} ,x=%-8.8X{TX} ,l=%-5.5level ,u=%-8.8X{U} ,c=%-30.30logger{0} ,f=%-20.20method ,t=%-10.10t ,m=%m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/>
      
    	<!--
    	<property name="CONSOLE_LOG_PATTERN" value="%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(- - -){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/>
      <property name="FILE_LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} ${LOG_LEVEL_PATTERN:-%5p} ${PID:- } - - - [%t] %-40.40logger{39} : %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/> 
      -->
      
    	<appender name="DEBUG_LEVEL_REMAPPER" class="org.springframework.boot.logging.logback.LevelRemappingAppender">
    		<destinationLogger>org.springframework.boot</destinationLogger>
    	</appender>
    
    	<logger name="org.apache.catalina.startup.DigesterFactory" level="ERROR"/>
    	<logger name="org.apache.catalina.util.LifecycleBase" level="ERROR"/>
    	<logger name="org.apache.coyote.http11.Http11NioProtocol" level="WARN"/>
    	<logger name="org.apache.sshd.common.util.SecurityUtils" level="WARN"/>
    	<logger name="org.apache.tomcat.util.net.NioSelectorPool" level="WARN"/>
    	<logger name="org.crsh.plugin" level="WARN"/>
    	<logger name="org.crsh.ssh" level="WARN"/>
    	<logger name="org.eclipse.jetty.util.component.AbstractLifeCycle" level="ERROR"/>
    	<logger name="org.hibernate.validator.internal.util.Version" level="WARN"/>
    	<logger name="org.springframework.boot.actuate.autoconfigure.CrshAutoConfiguration" level="WARN"/>
    	<logger name="org.springframework.boot.actuate.endpoint.jmx" additivity="false">
    		<appender-ref ref="DEBUG_LEVEL_REMAPPER"/>
    	</logger>
    	<logger name="org.thymeleaf" additivity="false">
    		<appender-ref ref="DEBUG_LEVEL_REMAPPER"/>
    	</logger>
    
    
    <!--	<property name="LOG_FILE" value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}/}spring.log}"/> -->
    
    	<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
    		<encoder>
    			<pattern>${CONSOLE_LOG_PATTERN}</pattern>
    			<charset>utf8</charset>
    		</encoder>
    	</appender>
    <!--
    <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
    		<encoder>
    			<pattern>${FILE_LOG_PATTERN}</pattern>
    		</encoder>
    		<file>${LOG_FILE}</file>
    		<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
    			<fileNamePattern>${LOG_FILE}.%i</fileNamePattern>
    		</rollingPolicy>
    		<triggeringPolicy
    			class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
    			<MaxFileSize>10MB</MaxFileSize>
    		</triggeringPolicy>
    	</appender>
    -->
    
        <appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"><File>${LOG_PATH}/debug.log</File>    
            <filter class="ch.qos.logback.classic.filter.LevelFilter">
              <level>DEBUG</level>
              <onMatch>ACCEPT</onMatch>
            </filter>
            <filter class="ch.qos.logback.classic.filter.LevelFilter">
              <level>INFO</level>
              <onMatch>ACCEPT</onMatch>
            </filter>
            <filter class="ch.qos.logback.classic.filter.LevelFilter">
              <level>TRACE</level>
              <onMatch>ACCEPT</onMatch>
            </filter>
            <filter class="ch.qos.logback.classic.filter.LevelFilter">
              <level>WARN</level>
              <onMatch>ACCEPT</onMatch>
            </filter>
            <filter class="ch.qos.logback.classic.filter.LevelFilter">
              <level>ERROR</level>
              <onMatch>ACCEPT</onMatch>
            </filter>    
            <encoder><charset>utf-8</charset><pattern>${LOG_PATTERN}</pattern></encoder>
            <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"><FileNamePattern>${LOG_ARCHIVE_PREFIX}debug.log</FileNamePattern><maxHistory>${LOG_ARCHIVE_DAYS}</maxHistory></rollingPolicy>
        </appender>
    
        <appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"><File>${LOG_PATH}/info.log</File>
            <filter class="ch.qos.logback.classic.filter.LevelFilter">
              <level>DEBUG</level>
              <onMatch>DENY</onMatch>
            </filter>
            <filter class="ch.qos.logback.classic.filter.LevelFilter">
              <level>INFO</level>
              <onMatch>ACCEPT</onMatch>
            </filter>
            <filter class="ch.qos.logback.classic.filter.LevelFilter">
              <level>TRACE</level>
              <onMatch>DENY</onMatch>
            </filter>
            <filter class="ch.qos.logback.classic.filter.LevelFilter">
              <level>WARN</level>
              <onMatch>ACCEPT</onMatch>
            </filter>
            <filter class="ch.qos.logback.classic.filter.LevelFilter">
              <level>ERROR</level>
              <onMatch>ACCEPT</onMatch>
            </filter>
            <encoder><charset>utf-8</charset><pattern>${LOG_PATTERN}</pattern></encoder>
            <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"><FileNamePattern>${LOG_ARCHIVE_PREFIX}info.log</FileNamePattern><maxHistory>${LOG_ARCHIVE_DAYS}</maxHistory></rollingPolicy>
        </appender>
    
        <appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"><File>${LOG_PATH}/error.log</File>
            <filter class="ch.qos.logback.classic.filter.LevelFilter">
              <level>DEBUG</level>
              <onMatch>DENY</onMatch>
            </filter>
            <filter class="ch.qos.logback.classic.filter.LevelFilter">
              <level>INFO</level>
              <onMatch>DENY</onMatch>
            </filter>
            <filter class="ch.qos.logback.classic.filter.LevelFilter">
              <level>TRACE</level>
              <onMatch>DENY</onMatch>
            </filter>
            <filter class="ch.qos.logback.classic.filter.LevelFilter">
              <level>WARN</level>
              <onMatch>ACCEPT</onMatch>
            </filter>
            <filter class="ch.qos.logback.classic.filter.LevelFilter">
              <level>ERROR</level>
              <onMatch>ACCEPT</onMatch>
            </filter>
            <encoder><charset>utf-8</charset><pattern>${LOG_PATTERN}${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}</pattern></encoder>
            <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"><FileNamePattern>${LOG_ARCHIVE_PREFIX}error.log</FileNamePattern><maxHistory>${LOG_ARCHIVE_DAYS}</maxHistory></rollingPolicy>
        </appender>
    
        <appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
            <queueSize>512</queueSize>
            <appender-ref ref="INFO_FILE" />
    		    <appender-ref ref="ERROR_FILE" />
            <appender-ref ref="DEBUG_FILE"/>
        </appender>
    
    	<root level="INFO">
    		<appender-ref ref="CONSOLE" />
    		<appender-ref ref="DEBUG_FILE" />
    		<appender-ref ref="INFO_FILE" />
    		<appender-ref ref="ERROR_FILE" />
    	</root>
    
    
        
        <logger name="com.theice.asdlc" level="#logback.loglevel#"/>
    
        <logger name="javax.activation" level="WARN"/>
        <logger name="javax.mail" level="WARN"/>
        <logger name="javax.xml.bind" level="WARN"/>
        <logger name="ch.qos.logback" level="WARN"/>
        <logger name="com.codahale.metrics" level="WARN"/>
        <logger name="com.ryantenney" level="WARN"/>
        <logger name="com.sun" level="WARN"/>
        <logger name="com.zaxxer" level="WARN"/>
        <logger name="org.apache" level="WARN"/>
        <logger name="org.apache.catalina.startup.DigesterFactory" level="OFF"/>
        <logger name="org.bson" level="WARN"/>
        <logger name="org.hibernate.validator" level="WARN"/>
        <logger name="org.hibernate" level="WARN"/>
        <logger name="org.hibernate.ejb.HibernatePersistence" level="OFF"/>
        <logger name="org.springframework" level="WARN"/>
        <logger name="org.springframework.web" level="WARN"/>
        <logger name="org.springframework.security" level="WARN"/>
        <logger name="org.springframework.cache" level="WARN"/>
        <logger name="org.thymeleaf" level="WARN"/>
        <logger name="org.xnio" level="WARN"/>
        <logger name="springfox" level="WARN"/>
        <logger name="sun.rmi" level="WARN"/>
        <logger name="liquibase" level="WARN"/>
        <logger name="sun.rmi.transport" level="WARN"/>
    
        <contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
            <resetJUL>true</resetJUL>
        </contextListener>
    
        <root level="#logback.loglevel#">
            <appender-ref ref="CONSOLE"/>
        </root>
    
    </configuration>

    0 讨论(0)
  • 2021-02-06 05:21

    I haven't dug into this but will soon. I think it works similar to log4j/slf4j. You need to define an appender with a file specification. http://logback.qos.ch/manual/configuration.html

    Rob

    0 讨论(0)
  • 2021-02-06 05:26

    Ok,

    So here the answer to this:

    There is a xml file logback.xml that you can find in the resources directory.

    Configuration for console:

    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <charset>utf-8</charset>
            <Pattern>[%p] %c - %m%n</Pattern>
        </encoder>
    </appender>
    

    For a File

    <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
      ...
    </appender>
    

    Reference it at the end of the file

    <root level="${logback.loglevel}">
        <appender-ref ref="CONSOLE"/> <!-- For Console Log -->
        <appender-ref ref="FILE"/> <!-- For File Log -->
    </root>
    
    0 讨论(0)
  • 2021-02-06 05:26

    In Dev mode, modifying logback-spring.xml only creates log file but does not log data to this file (file is created but empty). I had to add "file" key into "logging" key in applicatio-dev.yml file:

    logging:

    file: *path/log_file_name.log* 
    

    (for example:

    logging:

    file: logs/application1.log
    

    )

    0 讨论(0)
提交回复
热议问题