diff --git a/slf4j-logback/pom.xml b/slf4j-logback/pom.xml new file mode 100644 index 0000000..b5e9f21 --- /dev/null +++ b/slf4j-logback/pom.xml @@ -0,0 +1,80 @@ + + + 4.0.0 + + + com.ossez.demo + java-logging + 1.0.1 + + + slf4j-logback + + + UTF-8 + 1.8 + 1.2.3 + 1.6.2 + + + + + + + ch.qos.logback + logback-classic + ${logback.version} + + + + + com.sun.mail + javax.mail + ${javax.mail.version} + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.0 + + ${java.version} + ${java.version} + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.0 + + + + package + + shade + + + + + HelloWorld + + + + + + + + + + + \ No newline at end of file diff --git a/slf4j-logback/src/main/java/com/ossez/demo/logging/logback/HelloWorld.java b/slf4j-logback/src/main/java/com/ossez/demo/logging/logback/HelloWorld.java new file mode 100644 index 0000000..81b445f --- /dev/null +++ b/slf4j-logback/src/main/java/com/ossez/demo/logging/logback/HelloWorld.java @@ -0,0 +1,23 @@ +package com.ossez.demo.logging.logback; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class HelloWorld { + + private static final Logger logger = LoggerFactory.getLogger(HelloWorld.class); + + public static void main(String[] args) { + + logger.debug("Hello from Logback"); + + //while (true)//test rotate file + logger.debug("getNumber() : {}", getNumber()); + + } + + static int getNumber() { + return 5; + } + +} diff --git a/slf4j-logback/src/main/java/com/ossez/demo/logging/logback/HelloWorldError.java b/slf4j-logback/src/main/java/com/ossez/demo/logging/logback/HelloWorldError.java new file mode 100644 index 0000000..d724953 --- /dev/null +++ b/slf4j-logback/src/main/java/com/ossez/demo/logging/logback/HelloWorldError.java @@ -0,0 +1,24 @@ +package com.ossez.demo.logging.logback; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class HelloWorldError { + + private static final Logger logger = LoggerFactory.getLogger(HelloWorldError.class); + + public static void main(String[] args) { + + try { + System.out.println(getData()); + } catch (IllegalArgumentException e) { + logger.error("{}", e); + } + + } + + static int getData() throws IllegalArgumentException { + throw new IllegalArgumentException("Sorry IllegalArgumentException!"); + } + +}