feat(slf4j): initial commit
This commit is contained in:
parent
13175399f6
commit
fc1056796f
|
@ -0,0 +1,31 @@
|
||||||
|
|
||||||
|
# Files
|
||||||
|
.classpath
|
||||||
|
.externalToolBuilders
|
||||||
|
.gradle
|
||||||
|
.project
|
||||||
|
.pydevproject
|
||||||
|
.settings
|
||||||
|
.sonar
|
||||||
|
*~
|
||||||
|
*.ipr
|
||||||
|
*.iml
|
||||||
|
*.iws
|
||||||
|
*.swp
|
||||||
|
*.DS_Store
|
||||||
|
*.snap.debug
|
||||||
|
dependency-reduced-pom.xml
|
||||||
|
|
||||||
|
# Directories
|
||||||
|
.idea/
|
||||||
|
.run/
|
||||||
|
.venv/
|
||||||
|
_site/
|
||||||
|
build/
|
||||||
|
dist/
|
||||||
|
docs/_build/
|
||||||
|
gen-java/
|
||||||
|
gen-javabean/
|
||||||
|
gen-py/
|
||||||
|
node_modules/
|
||||||
|
target/
|
|
@ -0,0 +1,4 @@
|
||||||
|
# Overview
|
||||||
|
This project shows an example how to use Simple Logging Facade for Java (slf4j).
|
||||||
|
|
||||||
|
# Links
|
|
@ -0,0 +1,95 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<name>slf4j</name>
|
||||||
|
<description>description</description>
|
||||||
|
<url>https://swingbe.de</url>
|
||||||
|
<groupId>org.swingbe.de</groupId>
|
||||||
|
<artifactId>slf4j</artifactId>
|
||||||
|
<version>0.0.1</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<licenses>
|
||||||
|
<license>
|
||||||
|
<name>GNU General Public License</name>
|
||||||
|
<url>https://www.gnu.org/licenses/gpl-3.0.txt</url>
|
||||||
|
</license>
|
||||||
|
</licenses>
|
||||||
|
|
||||||
|
<scm>
|
||||||
|
<url>https://github.com/Software-Ingenieur-Begerad/sandbox-java</url>
|
||||||
|
</scm>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<!-- Other properties -->
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
|
<configuration>
|
||||||
|
<!-- Target Java versions -->
|
||||||
|
<release>11</release>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>3.2.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<filters>
|
||||||
|
<filter>
|
||||||
|
<!-- exclude signatures from merged JAR to avoid invalid signature messages -->
|
||||||
|
<artifact>*:*</artifact>
|
||||||
|
<excludes>
|
||||||
|
<exclude>META-INF/*.SF</exclude>
|
||||||
|
<exclude>META-INF/*.DSA</exclude>
|
||||||
|
<exclude>META-INF/*.RSA</exclude>
|
||||||
|
</excludes>
|
||||||
|
</filter>
|
||||||
|
</filters>
|
||||||
|
<!-- The shaded JAR will not be the main artifact for the project, it will be attached
|
||||||
|
for deployment in the way source and docs are. -->
|
||||||
|
<shadedArtifactAttached>true
|
||||||
|
</shadedArtifactAttached>
|
||||||
|
<shadedClassifierName>shaded</shadedClassifierName>
|
||||||
|
<transformers>
|
||||||
|
<transformer
|
||||||
|
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
|
||||||
|
<transformer
|
||||||
|
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||||
|
<manifestEntries>
|
||||||
|
<Main-Class>de.swingbe.slf4j.Main
|
||||||
|
</Main-Class>
|
||||||
|
</manifestEntries>
|
||||||
|
</transformer>
|
||||||
|
</transformers>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-slf4j-impl</artifactId>
|
||||||
|
<version>2.9.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,13 @@
|
||||||
|
package de.swingbe.slf4j;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
public class Bar {
|
||||||
|
public final static Logger LOG = LoggerFactory.getLogger(Bar.class);
|
||||||
|
|
||||||
|
public boolean doIt() {
|
||||||
|
LOG.error("Did it again!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package de.swingbe.slf4j;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
public final static Logger LOG = LoggerFactory.getLogger(Main.class);
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
System.out.println("Hello world!");
|
||||||
|
|
||||||
|
LOG.debug("Debug Message Logged !!!");
|
||||||
|
LOG.info("Info Message Logged !!!");
|
||||||
|
LOG.error("Error Message Logged !!!",
|
||||||
|
new NullPointerException("NullError"));
|
||||||
|
|
||||||
|
String variable = "Hello John";
|
||||||
|
LOG.debug("Printing variable value: {}", variable);
|
||||||
|
|
||||||
|
|
||||||
|
LOG.trace("Entering application.");
|
||||||
|
Bar bar = new Bar();
|
||||||
|
if (!bar.doIt()) {
|
||||||
|
LOG.error("Didn't do it.");
|
||||||
|
}
|
||||||
|
LOG.trace("Exiting application.");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Configuration status="INFO">
|
||||||
|
<Appenders>
|
||||||
|
<RollingFile name="rollingFile"
|
||||||
|
fileName="sizeRolling.log"
|
||||||
|
filePattern="sizeRolling-%d{yyyy-MM-dd}.log"
|
||||||
|
ignoreExceptions="false"
|
||||||
|
>
|
||||||
|
<PatternLayout>
|
||||||
|
<Pattern>[%-5p] %d{yyyy-MM-dd HH:mm:ss.SSS} %c{1} %m%n</Pattern>
|
||||||
|
</PatternLayout>
|
||||||
|
<Policies>
|
||||||
|
<SizeBasedTriggeringPolicy size="21MB"/>
|
||||||
|
</Policies>
|
||||||
|
<DefaultRolloverStrategy max="5"/>
|
||||||
|
</RollingFile>
|
||||||
|
|
||||||
|
<Console name="console" target="SYSTEM_OUT">
|
||||||
|
<PatternLayout
|
||||||
|
pattern="[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} %c{1} - %msg%n"/>
|
||||||
|
</Console>
|
||||||
|
</Appenders>
|
||||||
|
<Loggers>
|
||||||
|
<Logger name="de.swingbe" level="all" additivity="true">
|
||||||
|
<appender-ref ref="rollingFile" level="debug"/>
|
||||||
|
</Logger>
|
||||||
|
<Root level="debug" additivity="false">
|
||||||
|
<appender-ref ref="console"/>
|
||||||
|
</Root>
|
||||||
|
</Loggers>
|
||||||
|
|
||||||
|
</Configuration>
|
Loading…
Reference in New Issue