Skip to content

Commit

Permalink
IGNITE-16650 Migrate logging to log4j2. (apache#10152)
Browse files Browse the repository at this point in the history
  • Loading branch information
petrov-mg authored Jul 21, 2022
1 parent 280b212 commit 4d5cd30
Show file tree
Hide file tree
Showing 145 changed files with 1,183 additions and 4,108 deletions.
1 change: 0 additions & 1 deletion assembly/libs/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ The following modules are available:
- ignite-indexing (for SQL querying and indexing)
- ignite-jcl (for Apache Commons logging)
- ignite-jta (for XA integration)
- ignite-logj4 (for Log4j logging)
- ignite-log4j2 (for Log4j 2 logging)
- ignite-rest-http (for HTTP REST messages)
- ignite-schedule (for Cron-based task scheduling)
Expand Down
5 changes: 0 additions & 5 deletions assembly/release-base.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@
<outputDirectory>/config</outputDirectory>
</file>

<file>
<source>config/ignite-log4j2.xml</source>
<outputDirectory>/config</outputDirectory>
</file>

<file>
<source>config/java.util.logging.properties</source>
<outputDirectory>/config</outputDirectory>
Expand Down
191 changes: 66 additions & 125 deletions config/ignite-log4j.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,134 +17,75 @@
limitations under the License.
-->

<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN"
"http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd">

<!--
Default log4j configuration for Ignite.
-->
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
<!--
Logs System.out messages to console.
Note, this appender is disabled by default.
To enable, uncomment the section below and also CONSOLE appender in the <root> element.
-->
<!--
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out"/>
<param name="Threshold" value="DEBUG"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%d{ISO8601}][%-5p][%t][%c{1}] %m%n"/>
</layout>
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="levelMin" value="DEBUG"/>
<param name="levelMax" value="WARN"/>
</filter>
</appender>
-->

<!--
Logs all ERROR messages to console.
-->
<appender name="CONSOLE_ERR" class="org.apache.log4j.ConsoleAppender">
<!-- Log to STDERR. -->
<param name="Target" value="System.err"/>

<!-- Log from ERROR and higher (change to WARN if needed). -->
<param name="Threshold" value="ERROR"/>

<!-- The default pattern: Date Priority [Category] Message\n -->
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%d{ISO8601}][%-5p][%t][%c{1}] %m%n"/>
</layout>
</appender>

<!--
Logs all output to specified file.
By default, the logging goes to IGNITE_HOME/work/log folder
-->
<appender name="FILE" class="org.apache.ignite.logger.log4j.Log4jRollingFileAppender">
<param name="Threshold" value="DEBUG"/>
<param name="File" value="${IGNITE_HOME}/work/log/ignite.log"/>
<param name="Append" value="true"/>
<param name="MaxFileSize" value="10MB"/>
<param name="MaxBackupIndex" value="10"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%d{ISO8601}][%-5p][%t][%c{1}] %m%n"/>
</layout>
</appender>

<!--
<category name="org.apache.ignite">
<level value="DEBUG"/>
</category>
-->

<!--
Uncomment to disable courtesy notices, such as SPI configuration
consistency warnings.
-->
<!--
<category name="org.apache.ignite.CourtesyConfigNotice">
<level value="OFF"/>
</category>
-->

<category name="org.springframework">
<level value="WARN"/>
</category>

<category name="org.eclipse.jetty">
<level value="WARN"/>
</category>

<!--
Avoid warnings about failed bind attempt when multiple nodes running on the same host.
-->
<category name="org.eclipse.jetty.util.log">
<level value="ERROR"/>
</category>

<category name="org.eclipse.jetty.util.component">
<level value="ERROR"/>
</category>

<category name="com.amazonaws">
<level value="WARN"/>
</category>
<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"/>
</Console>

<Console name="CONSOLE_ERR" target="SYSTEM_ERR">
<PatternLayout pattern="[%d{ISO8601}][%-5p][%t][%c{1}]%notEmpty{[%markerSimpleName]} %m%n"/>
</Console>

<File name="CONSISTENCY" fileName="${sys:IGNITE_HOME}/work/log/consistency.log">
<PatternLayout>
<Pattern>"[%d{ISO8601}][%-5p][%t][%c{1}] %m%n"</Pattern>
</PatternLayout>
</File>

<Routing name="FILE">
<Routes pattern="$${sys:nodeId}">
<Route>
<RollingFile name="Rolling-${sys:nodeId}" fileName="${sys:IGNITE_HOME}/work/log/${sys:appId}-${sys:nodeId}.log"
filePattern="${sys:IGNITE_HOME}/work/log/${sys:appId}-${sys:nodeId}-%i-%d{yyyy-MM-dd}.log.gz">
<PatternLayout pattern="[%d{ISO8601}][%-5p][%t][%c{1}]%notEmpty{[%markerSimpleName]} %m%n"/>
<Policies>
<TimeBasedTriggeringPolicy interval="6" modulate="true" />
<SizeBasedTriggeringPolicy size="10 MB" />
</Policies>
</RollingFile>
</Route>
</Routes>
</Routing>
</Appenders>

<Loggers>
<!--
<Logger name="org.apache.ignite" level=DEBUG/>
-->

<!--
Consistency repair section.
Repaired data should not be logged to the same log file by default.
-->
<category name="org.apache.ignite.internal.visor.consistency" additivity="false">
<appender-ref ref="CONSISTENCY"/>
<level value="INFO"/>
</category>
<!--
Uncomment to disable courtesy notices, such as SPI configuration
consistency warnings.
-->
<!--
<Logger name="org.apache.ignite.CourtesyConfigNotice" level=OFF/>
-->

<appender name="CONSISTENCY" class="org.apache.log4j.FileAppender">
<param name="File" value="${IGNITE_HOME}/work/log/consistency.log"/>
<param name="Append" value="true"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%d{ISO8601}][%-5p][%t][%c{1}] %m%n"/>
</layout>
</appender>
<Logger name="org.springframework" level="WARN"/>
<Logger name="org.eclipse.jetty" level="WARN"/>

<!-- Default settings. -->
<root>
<!-- Print out all info by default. -->
<level value="INFO"/>
<Logger name="org.apache.ignite.internal.visor.consistency" additivity="false" level="INFO">
<AppenderRef ref="CONSISTENCY"/>
</Logger>

<!-- Uncomment to enable logging to console. -->
<!--
<appender-ref ref="CONSOLE"/>
Avoid warnings about failed bind attempt when multiple nodes running on the same host.
-->

<appender-ref ref="CONSOLE_ERR"/>
<appender-ref ref="FILE"/>
</root>
</log4j:configuration>
<Logger name="org.eclipse.jetty.util.log" level="ERROR"/>
<Logger name="org.eclipse.jetty.util.component" level="ERROR"/>

<Logger name="com.amazonaws" level="WARN"/>

<Root level="INFO">
<!-- Uncomment to enable logging to console. -->
<!--
<AppenderRef ref="CONSOLE" level="DEBUG"/>
-->

<AppenderRef ref="CONSOLE_ERR" level="ERROR"/>
<AppenderRef ref="FILE" level="DEBUG"/>
</Root>
</Loggers>
</Configuration>
5 changes: 0 additions & 5 deletions docs/_docs/code-snippets/java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@
<artifactId>ignite-log4j2</artifactId>
<version>${ignite.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>ignite-log4j</artifactId>
<version>${ignite.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>ignite-jcl</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,10 @@
import org.apache.ignite.Ignition;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.logger.jcl.JclLogger;
import org.apache.ignite.logger.log4j.Log4JLogger;
import org.apache.ignite.logger.log4j2.Log4J2Logger;
import org.apache.ignite.logger.slf4j.Slf4jLogger;

public class Logging {

void log4j() throws IgniteCheckedException {

// tag::log4j[]
IgniteConfiguration cfg = new IgniteConfiguration();

IgniteLogger log = new Log4JLogger("log4j-config.xml");

cfg.setGridLogger(log);

// Start a node.
try (Ignite ignite = Ignition.start(cfg)) {
ignite.log().info("Info Message Logged!");
}
// end::log4j[]
}

void log4j2() throws IgniteCheckedException {
// tag::log4j2[]
IgniteConfiguration cfg = new IgniteConfiguration();
Expand Down
107 changes: 0 additions & 107 deletions docs/_docs/code-snippets/xml/log4j-config.xml

This file was deleted.

Loading

0 comments on commit 4d5cd30

Please sign in to comment.