add log4j example

This commit is contained in:
Tom Hombergs
2021-06-05 07:50:27 +10:00
parent dbdd4d20cb
commit 0a37bcbba9
5 changed files with 88 additions and 2 deletions

View File

@@ -17,7 +17,7 @@ jobs:
matrix:
# The MODULE environment variable is evaluated in build-all.sh to run a subset
# of the builds. This way, multiple modules can be built in parallel.
module: [ "module1", "module2", "module3", "module4", "module5" ]
module: [ "module1", "module2", "module3", "module4", "module5", "module6" ]
steps:

View File

@@ -82,10 +82,20 @@ build_maven_module() {
}
}
if [[ "$MODULE" == "module5" ]]
if [[ "$MODULE" == "module6" ]]
then
# ADD NEW MODULES HERE
# (add new modules above the rest so you get quicker feedback if it fails)
build_maven_module "logging/log4j"
echo ""
echo "+++"
echo "+++ MODULE 6 SUCCESSFUL"
echo "+++"
fi
if [[ "$MODULE" == "module5" ]]
then
build_gradle_module "spring-boot/hazelcast/hazelcast-embedded-cache"
build_gradle_module "spring-boot/hazelcast/hazelcast-client-server"
build_maven_module "core-java/heapdump"

39
logging/log4j/pom.xml Normal file
View File

@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.reflectoring</groupId>
<artifactId>logging-log4j</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.14.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.14.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.14.1</version>
</dependency>
<dependency>
<groupId>io.logz.log4j2</groupId>
<artifactId>logzio-log4j2-appender</artifactId>
<version>1.0.12</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,17 @@
package io.reflectoring;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Main {
public static void main(String[] args) {
Logger logger = LoggerFactory.getLogger(Main.class);
logger.debug("This is a debug message");
logger.info("This is an info message");
logger.warn("This is a warn message");
logger.error("This is an error message");
}
}

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<Console name="CONSOLE" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
<LogzioAppender name="LOGZIO">
<logzioToken>eoUyeKjGgqfrMGVWeZLfTyYCAmBTbhvh</logzioToken>
<logzioUrl>https://listener.logz.io:8071</logzioUrl>
<logzioType>java</logzioType>
</LogzioAppender>
</Appenders>
<Loggers>
<Root level="INFO">
<AppenderRef ref="${env:LOG_APPENDER:-CONSOLE}"/>
</Root>
</Loggers>
</Configuration>