Skip to content

Commit

Permalink
[enhancement][core][rdbms] Introduce console.enabled property to co…
Browse files Browse the repository at this point in the history
…ntrol console logging

In batch mode, console logging is often unnecessary. This update allows users to disable console logs by specifying `-Dconsole.enabled=false` at runtime. This can help reduce clutter and improve performance in batch processing scenarios.
  • Loading branch information
wgzhao committed Nov 5, 2024
1 parent 9b7fd3e commit b19cba6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
8 changes: 8 additions & 0 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@
<version>${logback.version}</version>
</dependency>

<!-- enable logback jansi and condition -->
<dependency>
<groupId>org.codehaus.janino</groupId>
<artifactId>janino</artifactId>
<version>3.1.12</version>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
Expand Down
30 changes: 19 additions & 11 deletions core/src/main/conf/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,24 @@

<configuration>
<property name="log.dir" value="${addax.log}/" />
<!-- console output -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<withJansi>true</withJansi>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>
%cyan(%d{yyyy-MM-dd HH:mm:ss.SSS}) %green([%12thread]) %highlight(%-5level) %magenta(%-20logger{0}) - %msg%n
</pattern>
</encoder>
</appender>
<!-- Suppress all internal status messages -->
<statusListener class="ch.qos.logback.core.status.NopStatusListener" />
<if condition='!isDefined("console.enabled") || "${console.enabled}" == "true"' >
<then>
<!-- console output -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<withJansi>true</withJansi>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>
%cyan(%d{yyyy-MM-dd HH:mm:ss.SSS}) %green([%12thread]) %highlight(%-5level) %magenta(%-20logger{0}) - %msg%n
</pattern>
</encoder>
</appender>
<root level="${logLevel:-INFO}">
<appender-ref ref="STDOUT" />
</root>
</then>
</if>

<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>${log.dir}/${log.file.name}</file>
Expand All @@ -43,7 +52,6 @@
<logger name="org.mongodb.driver" level="WARN"> </logger>

<root level="${loglevel:-INFO}">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>
</configuration>
</configuration>

0 comments on commit b19cba6

Please sign in to comment.