From e2f9ca8b8d5adaaf79e84029288607a30b515db4 Mon Sep 17 00:00:00 2001 From: Louis Vallat Date: Sun, 25 Oct 2020 14:38:03 +0100 Subject: [PATCH] Switched to a logger system instead of System.out Signed-off-by: Louis Vallat --- build.gradle | 13 +++++- .../java/xyz/vallat/louis/MovieQuoteBot.java | 6 ++- src/main/resources/logback.xml | 42 +++++++++++++++++++ 3 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 src/main/resources/logback.xml diff --git a/build.gradle b/build.gradle index 4e81683..007a845 100644 --- a/build.gradle +++ b/build.gradle @@ -1,13 +1,23 @@ plugins { id 'java' + id 'application' } group 'xyz.vallat.louis' version '0.1-SNAPSHOT' +apply plugin : 'java' +ext { + javaMainClass = 'xyz.vallat.louis.MovieQuoteBot' +} + +application { + mainClassName = javaMainClass +} + jar { manifest { - attributes 'Main-Class': 'xyz.vallat.louis.MovieQuoteBot' + attributes 'Main-Class': javaMainClass } duplicatesStrategy = DuplicatesStrategy.EXCLUDE @@ -21,4 +31,5 @@ repositories { } dependencies { + implementation 'ch.qos.logback:logback-classic:1.2.3' } \ No newline at end of file diff --git a/src/main/java/xyz/vallat/louis/MovieQuoteBot.java b/src/main/java/xyz/vallat/louis/MovieQuoteBot.java index 1015a37..7e27662 100644 --- a/src/main/java/xyz/vallat/louis/MovieQuoteBot.java +++ b/src/main/java/xyz/vallat/louis/MovieQuoteBot.java @@ -1,9 +1,13 @@ package xyz.vallat.louis; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class MovieQuoteBot { public static void main(String[] args) { - System.out.println("Hello World!"); + Logger logger = LoggerFactory.getLogger(MovieQuoteBot.class.getCanonicalName()); + logger.debug("Hello World!"); } } diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml new file mode 100644 index 0000000..160c928 --- /dev/null +++ b/src/main/resources/logback.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + logs/d4j.%d{yyyy-MM-dd}.%i.log + 100MB + 90 + + + UTF-8 + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %-40.40logger{39} : %msg%n + + true + + + + + 512 + + + + + + + + + + \ No newline at end of file