This is an automated email from the ASF dual-hosted git repository.
ppa pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new b6efbea6895 IGNITE-17442 Added highlighting of log4j2 console output
(#10229)
b6efbea6895 is described below
commit b6efbea6895c9a821f12036dd0fb3d6bd36c8f21
Author: Pavel Pereslegin <[email protected]>
AuthorDate: Wed Sep 14 16:05:02 2022 +0300
IGNITE-17442 Added highlighting of log4j2 console output (#10229)
---
config/ignite-log4j.xml | 16 +++++++++++++---
docs/_docs/logging.adoc | 2 ++
modules/core/src/test/config/log4j2-test.xml | 13 +++++++++++--
parent/pom.xml | 2 +-
4 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/config/ignite-log4j.xml b/config/ignite-log4j.xml
index ee4e268927f..ab710c821c2 100644
--- a/config/ignite-log4j.xml
+++ b/config/ignite-log4j.xml
@@ -20,12 +20,21 @@
<Configuration monitorInterval="60">
<Appenders>
<Console name="CONSOLE" target="SYSTEM_OUT">
- <PatternLayout
pattern="[%d{ISO8601}][%-5p][%t][%c{1}]%notEmpty{[%markerSimpleName]} %m%n"/>
- <ThresholdFilter level="ERROR" onMatch="DENY" onMismatch="ACCEPT"/>
+ <!-- Add the `disableAnsi="true"` property to the pattern layout
if you want to disable colors in the console output. -->
+ <PatternLayout
+ pattern="[%d{ISO8601}]%highlight{[%-5p]}{INFO=green,
DEBUG=green bold,
TRACE=blue}%style{[%t]}{magenta}%style{[%c{1}]}{cyan}%notEmpty{[%markerSimpleName]}
%m%n"/>
+ <ThresholdFilter level="WARN" onMatch="DENY" onMismatch="ACCEPT"/>
+ </Console>
+
+ <Console name="CONSOLE_WARN" target="SYSTEM_OUT">
+ <!-- Add the `disableAnsi="true"` property to the pattern layout
if you want to disable colors in the console output. -->
+ <PatternLayout pattern="%highlight{[%d{ISO8601}][%-5p][%t][%c{1}]
%m%n}{WARN=yellow bold}"/>
+ <ThresholdFilter level="WARN" onMatch="ACCEPT" onMismatch="DENY"/>
</Console>
<Console name="CONSOLE_ERR" target="SYSTEM_ERR">
- <PatternLayout
pattern="[%d{ISO8601}][%-5p][%t][%c{1}]%notEmpty{[%markerSimpleName]} %m%n"/>
+ <!-- Add the `disableAnsi="true"` property to the pattern layout
if you want to disable colors in the console output. -->
+ <PatternLayout pattern="%highlight{[%d{ISO8601}][%-5p][%t][%c{1}]
%m%n}{ERROR=bright red}"/>
</Console>
<File name="CONSISTENCY"
fileName="${sys:IGNITE_HOME}/work/log/consistency.log">
@@ -82,6 +91,7 @@
<!-- Uncomment to enable logging to console. -->
<!--
<AppenderRef ref="CONSOLE" level="DEBUG"/>
+ <AppenderRef ref="CONSOLE_WARN" level="WARN"/>
-->
<AppenderRef ref="CONSOLE_ERR" level="ERROR"/>
diff --git a/docs/_docs/logging.adoc b/docs/_docs/logging.adoc
index 09282617a48..e9a9f900ad5 100644
--- a/docs/_docs/logging.adoc
+++ b/docs/_docs/logging.adoc
@@ -77,6 +77,8 @@ In the above example, the path to `log4j2-config.xml` can be
either an absolute
NOTE: Log4j2 supports runtime reconfiguration, i.e. changes in the
configuration file is applied without the need to restart the application.
+NOTE: `log4j2-config.xml` enables colorization of console output by default.
This feature works out of the box on many operating systems, except for
Windows. If you want to enable this feature on Windows, please follow the
https://logging.apache.org/log4j/2.x/manual/layouts.html#ANSI_Styling_on_Windows[official
log4j2 instructions].
+
== Using JCL
NOTE: Before using JCL, enable the link:setup#enabling-modules[ignite-jcl]
module.
diff --git a/modules/core/src/test/config/log4j2-test.xml
b/modules/core/src/test/config/log4j2-test.xml
index ee2104f38d3..8b0d439aad5 100644
--- a/modules/core/src/test/config/log4j2-test.xml
+++ b/modules/core/src/test/config/log4j2-test.xml
@@ -18,14 +18,23 @@
-->
<Configuration>
+ <Properties>
+ <!-- Set the `IGNITE_NO_LOG_COLOR` environment variable to completely
disable colors in the console output. -->
+ <Property
name="disableAnsi">${sys:IGNITE_NO_LOG_COLOR:-false}</Property>
+ </Properties>
+
<Appenders>
<Console name="CONSOLE" target="SYSTEM_OUT">
- <PatternLayout
pattern="[%d{ISO8601}][%-5p][%t][%c{1}]%notEmpty{[%markerSimpleName]} %m%n"/>
+ <PatternLayout
+ pattern="[%d{ISO8601}]%highlight{[%-5p]}{INFO=green,
DEBUG=green bold,
TRACE=blue}%style{[%t]}{magenta}%style{[%c{1}]}{cyan}%notEmpty{[%markerSimpleName]}
%m%n"
+ disableAnsi="${disableAnsi}"/>
<LevelRangeFilter minLevel="INFO" maxLevel="DEBUG"/>
</Console>
<Console name="CONSOLE_ERR" target="SYSTEM_ERR">
- <PatternLayout pattern="[%d{ISO8601}][%-5p][%t][%c{1}] %m%n"/>
+ <PatternLayout
+ pattern="%highlight{[%d{ISO8601}][%-5p][%t][%c{1}]
%m%n}{FATAL=red blink, ERROR=default, WARN=yellow bold}"
+ disableAnsi="${disableAnsi}"/>
</Console>
<RollingFile name="FILE"
diff --git a/parent/pom.xml b/parent/pom.xml
index b95cb275be7..468e5a91b16 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -115,7 +115,7 @@
<jsonlib.version>2.4</jsonlib.version>
<jtidy.version>r938</jtidy.version>
<kafka.version>2.0.1</kafka.version>
- <log4j2.version>2.17.1</log4j2.version>
+ <log4j2.version>2.18.0</log4j2.version>
<lucene.bundle.version>7.4.0_1</lucene.bundle.version>
<lucene.version>8.11.2</lucene.version>
<lz4.version>1.8.0</lz4.version>