From 09221ab5695e99b2df1130ea923c39625ec85429 Mon Sep 17 00:00:00 2001 From: Alexander Alexeev Date: Thu, 10 Nov 2016 04:50:07 +0700 Subject: using slf4j + logback for logging --- juick-api/src/main/java/com/juick/api/Main.java | 2 -- juick-api/src/main/java/com/juick/api/Messages.java | 9 ++++----- juick-api/src/main/java/com/juick/api/SkypeEndpoint.java | 5 +++-- juick-api/src/main/java/com/juick/api/TelegramBotHook.java | 14 +++++++------- 4 files changed, 14 insertions(+), 16 deletions(-) (limited to 'juick-api/src/main/java/com/juick/api') diff --git a/juick-api/src/main/java/com/juick/api/Main.java b/juick-api/src/main/java/com/juick/api/Main.java index 3c5c3303..80cbecd4 100644 --- a/juick-api/src/main/java/com/juick/api/Main.java +++ b/juick-api/src/main/java/com/juick/api/Main.java @@ -54,7 +54,6 @@ import java.util.List; import java.util.Properties; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.logging.LogManager; /** * @@ -81,7 +80,6 @@ public class Main extends HttpServlet implements Stream.StreamListener { public void init() throws ServletException { super.init(); try { - LogManager.getLogManager().readConfiguration(getServletContext().getResourceAsStream("/WEB-INF/logging.properties")); Properties conf = new Properties(); conf.load(getServletContext().getResourceAsStream("/WEB-INF/juick.conf")); BasicDataSource dataSource = new BasicDataSource(); diff --git a/juick-api/src/main/java/com/juick/api/Messages.java b/juick-api/src/main/java/com/juick/api/Messages.java index b1c875d2..d02d0ffe 100644 --- a/juick-api/src/main/java/com/juick/api/Messages.java +++ b/juick-api/src/main/java/com/juick/api/Messages.java @@ -12,6 +12,8 @@ import com.juick.xmpp.Message; import com.juick.xmpp.Stream; import com.juick.xmpp.extensions.JuickMessage; import org.apache.commons.lang3.math.NumberUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.util.StringUtils; @@ -22,9 +24,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Objects; -import java.util.logging.Level; -import java.util.logging.Logger; -import java.util.stream.Collectors; /** * @@ -32,7 +31,7 @@ import java.util.stream.Collectors; */ public class Messages { - private static final Logger logger = Logger.getLogger(Messages.class.getName()); + private static final Logger logger = LoggerFactory.getLogger(Messages.class); JdbcTemplate sql; @@ -184,7 +183,7 @@ public class Messages { throw new Exception("Message not found"); } } catch (Exception e) { - logger.log(Level.SEVERE, "SETPOPULAR ERROR", e); + logger.error("SETPOPULAR ERROR", e); } } diff --git a/juick-api/src/main/java/com/juick/api/SkypeEndpoint.java b/juick-api/src/main/java/com/juick/api/SkypeEndpoint.java index cf141db2..74777305 100644 --- a/juick-api/src/main/java/com/juick/api/SkypeEndpoint.java +++ b/juick-api/src/main/java/com/juick/api/SkypeEndpoint.java @@ -3,16 +3,17 @@ package com.juick.api; import org.msbotframework4j.builder.bot.AbstractBot; import org.msbotframework4j.core.model.Message; import org.msbotframework4j.logging.BotLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.servlet.http.HttpServletRequest; import java.io.IOException; -import java.util.logging.Logger; /** * Created by vitalyster on 18.07.2016. */ public class SkypeEndpoint extends AbstractBot { - private static final Logger logger = Logger.getLogger(SkypeEndpoint.class.getName()); + private static final Logger logger = LoggerFactory.getLogger(SkypeEndpoint.class); @Override protected Message onMessage(Message request, BotLogger logger) { return null; diff --git a/juick-api/src/main/java/com/juick/api/TelegramBotHook.java b/juick-api/src/main/java/com/juick/api/TelegramBotHook.java index 038166cc..72981705 100644 --- a/juick-api/src/main/java/com/juick/api/TelegramBotHook.java +++ b/juick-api/src/main/java/com/juick/api/TelegramBotHook.java @@ -16,6 +16,8 @@ import com.pengrad.telegrambot.model.request.InlineKeyboardMarkup; import com.pengrad.telegrambot.request.SendMessage; import com.pengrad.telegrambot.response.SendResponse; import org.json.JSONObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.JdbcTemplate; @@ -26,8 +28,6 @@ import java.lang.reflect.InvocationTargetException; import java.util.List; import java.util.Map; import java.util.UUID; -import java.util.logging.Level; -import java.util.logging.Logger; import static com.juick.formatters.PlainTextFormatter.formatPost; import static com.juick.formatters.PlainTextFormatter.formatUrl; @@ -36,7 +36,7 @@ import static com.juick.formatters.PlainTextFormatter.formatUrl; * Created by vt on 12/05/16. */ public class TelegramBotHook { - private static final Logger logger = Logger.getLogger(TelegramBotHook.class.getName()); + private static final Logger logger = LoggerFactory.getLogger(TelegramBotHook.class); TelegramBot bot; WebSocket ws; @@ -90,7 +90,7 @@ public class TelegramBotHook { }); ws.connect(); } catch (Exception e) { - logger.log(Level.WARNING, "couldn't initialize telegram bot", e); + logger.warn("couldn't initialize telegram bot", e); } } @@ -112,7 +112,7 @@ public class TelegramBotHook { @Override public void onFailure(SendMessage request, IOException e) { - logger.log(Level.WARNING, "telegram failure", e); + logger.warn("telegram failure", e); } }); } @@ -132,7 +132,7 @@ public class TelegramBotHook { if (update.message() == null) { message = update.editedMessage(); if (message == null) { - logger.log(Level.SEVERE, "error parsing telegram update: " + update.toString()); + logger.error("error parsing telegram update: " + update.toString()); return; } } @@ -187,7 +187,7 @@ public class TelegramBotHook { @Override public void onFailure(SendMessage request, IOException e) { - logger.log(Level.WARNING, "telegram failure", e); + logger.warn("telegram failure", e); } }); } -- cgit v1.2.3