Skip to content

Commit

Permalink
Merge pull request #6958 from jhipster/logback-enhancements
Browse files Browse the repository at this point in the history
Logback enhancements
  • Loading branch information
pascalgrimaud authored Jul 22, 2023
2 parents 35fe97c + 22e18d7 commit 18d2d07
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration>
<configuration scan="true">
<include resource="org/springframework/boot/logging/logback/base.xml" />
<springProperty name="log.level" source="logging.level.root" defaultValue="INFO" />
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />

<!-- The FILE and ASYNC appenders are here as examples for a production configuration -->
Expand All @@ -21,10 +22,6 @@
<queueSize>512</queueSize>
<appender-ref ref="FILE"/>
</appender>
<root level="${logging.level.root}">
<appender-ref ref="ASYNC"/>
</root>
-->

<logger name="{{packageName}}" level="INFO" />
Expand All @@ -34,8 +31,15 @@
<logger name="org.springframework" level="WARN" />
<!-- jhipster-needle-logback-add-log -->

<!-- https://logback.qos.ch/manual/configuration.html#shutdownHook and https://jira.qos.ch/browse/LOGBACK-1090 -->
<shutdownHook class="ch.qos.logback.core.hook.DefaultShutdownHook" />
<root level="${log.level}">
<appender-ref ref="CONSOLE" />

<!-- The FILE and ASYNC appenders are here as examples for a production configuration -->
<!--
<appender-ref ref="FILE" />
<appender-ref ref="ASYNC"/>
-->
</root>

<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
<resetJUL>true</resetJUL>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration>
<configuration scan="true">
<include resource="org/springframework/boot/logging/logback/base.xml" />
<springProperty name="log.level" source="logging.level.root" defaultValue="INFO" />
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />

<logger name="{{packageName}}" level="OFF" />

<logger name="ch.qos.logback" level="WARN" />
<logger name="com.sun" level="WARN" />
<logger name="org.springframework" level="WARN" />
<!-- jhipster-needle-logback-add-log -->

<root level="${log.level}">
<appender-ref ref="CONSOLE" />
</root>
</configuration>
31 changes: 5 additions & 26 deletions src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
@@ -1,32 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration>
<configuration scan="true">
<include resource="org/springframework/boot/logging/logback/base.xml" />
<springProperty name="log.level" source="logging.level.root" defaultValue="INFO" />
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<include resource="org/springframework/boot/logging/logback/console-appender.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>
<root level="${logging.level.root}">
<appender-ref ref="ASYNC"/>
</root>
-->

<logger name="tech.jhipster.lite" level="INFO" />

<logger name="ch.qos.logback" level="WARN" />
Expand All @@ -36,8 +14,9 @@
<logger name="com.jackson" level="WARN" />
<!-- jhipster-needle-logback-add-log -->

<!-- https://logback.qos.ch/manual/configuration.html#shutdownHook and https://jira.qos.ch/browse/LOGBACK-1090 -->
<shutdownHook class="ch.qos.logback.core.hook.DefaultShutdownHook" />
<root level="${log.level}">
<appender-ref ref="CONSOLE" />
</root>

<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
<resetJUL>true</resetJUL>
Expand Down

0 comments on commit 18d2d07

Please sign in to comment.