diff --git a/pom.xml b/pom.xml index 37193d47..c6869154 100644 --- a/pom.xml +++ b/pom.xml @@ -39,7 +39,7 @@ 3.0.0 2.9.9 2.9.9.1 - 2.12.0 + 1.7.28 @@ -78,9 +78,9 @@ ${jackson.version} - org.apache.logging.log4j - log4j-core - ${log4j.version} + org.slf4j + slf4j-api + ${slf4j.version} @@ -108,9 +108,9 @@ - org.apache.logging.log4j - log4j-core - ${log4j.version} + org.slf4j + slf4j-api + ${slf4j.version} \ No newline at end of file diff --git a/telegrambots-abilities/pom.xml b/telegrambots-abilities/pom.xml index 9f8dc9b5..7f420e0a 100644 --- a/telegrambots-abilities/pom.xml +++ b/telegrambots-abilities/pom.xml @@ -78,6 +78,7 @@ 3.9 3.0.7 + 2.12.1 @@ -102,6 +103,16 @@ + + org.apache.logging.log4j + log4j-slf4j-impl + ${log4j.version} + + + org.apache.logging.log4j + log4j-core + ${log4j.version} + diff --git a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/bot/BaseAbilityBot.java b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/bot/BaseAbilityBot.java index d5f9c0ef..ca94dc0c 100644 --- a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/bot/BaseAbilityBot.java +++ b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/bot/BaseAbilityBot.java @@ -6,9 +6,9 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ListMultimap; import com.google.common.collect.Multimap; import org.apache.commons.io.IOUtils; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.telegram.abilitybots.api.db.DBContext; import org.telegram.abilitybots.api.objects.Ability; import org.telegram.abilitybots.api.objects.Locality; @@ -139,7 +139,7 @@ import static org.telegram.abilitybots.api.util.AbilityUtils.stripTag; */ @SuppressWarnings({"ConfusingArgumentToVarargsMethod", "UnusedReturnValue", "WeakerAccess", "unused", "ConstantConditions"}) public abstract class BaseAbilityBot extends DefaultAbsSender implements AbilityExtension { - private static final Logger log = LogManager.getLogger(BaseAbilityBot.class); + private static final Logger log = LoggerFactory.getLogger(BaseAbilityBot.class); // DB objects public static final String ADMINS = "ADMINS"; diff --git a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/db/MapDBContext.java b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/db/MapDBContext.java index a6977917..c39a7b3f 100644 --- a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/db/MapDBContext.java +++ b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/db/MapDBContext.java @@ -3,12 +3,12 @@ package org.telegram.abilitybots.api.db; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.mapdb.Atomic; import org.mapdb.DB; import org.mapdb.DBMaker; import org.mapdb.Serializer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.telegram.abilitybots.api.util.Pair; import java.io.IOException; @@ -35,7 +35,7 @@ import static org.mapdb.Serializer.JAVA; */ @SuppressWarnings({"unchecked", "WeakerAccess"}) public class MapDBContext implements DBContext { - private static final Logger log = LogManager.getLogger(MapDBContext.class); + private static final Logger log = LoggerFactory.getLogger(MapDBContext.class); private final DB db; private final ObjectMapper objectMapper; diff --git a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/objects/Ability.java b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/objects/Ability.java index c3004c8b..fb6b27a3 100644 --- a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/objects/Ability.java +++ b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/objects/Ability.java @@ -2,8 +2,8 @@ package org.telegram.abilitybots.api.objects; import com.google.common.base.MoreObjects; import com.google.common.base.Objects; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.telegram.telegrambots.meta.api.objects.Update; import java.util.Arrays; @@ -35,7 +35,7 @@ import static org.apache.commons.lang3.StringUtils.*; * @author Abbas Abou Daya */ public final class Ability { - private static final Logger log = LogManager.getLogger(Ability.class); + private static final Logger log = LoggerFactory.getLogger(Ability.class); private final String name; private final String info; diff --git a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/sender/SilentSender.java b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/sender/SilentSender.java index b5d48bfb..2745f757 100644 --- a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/sender/SilentSender.java +++ b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/sender/SilentSender.java @@ -1,7 +1,7 @@ package org.telegram.abilitybots.api.sender; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.telegram.telegrambots.meta.api.methods.BotApiMethod; import org.telegram.telegrambots.meta.api.methods.send.SendMessage; import org.telegram.telegrambots.meta.api.objects.Message; @@ -18,7 +18,7 @@ import java.util.Optional; * @author Abbas Abou Daya */ public class SilentSender { - private static final Logger log = LogManager.getLogger(SilentSender.class); + private static final Logger log = LoggerFactory.getLogger(SilentSender.class); private final MessageSender sender; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/ApiContext.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/ApiContext.java index a5a2e0ce..3859fa91 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/ApiContext.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/ApiContext.java @@ -4,8 +4,8 @@ import com.google.inject.AbstractModule; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Singleton; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.text.MessageFormat; import java.util.HashMap; @@ -16,7 +16,7 @@ import java.util.Map; * @version 1.0 */ public class ApiContext { - private static final Logger log = LogManager.getLogger(ApiContext.class); + private static final Logger log = LoggerFactory.getLogger(ApiContext.class); private static final Object lock = new Object(); private static Injector INJECTOR; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/exceptions/TelegramApiRequestException.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/exceptions/TelegramApiRequestException.java index 01d52b38..1dd7bcf7 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/exceptions/TelegramApiRequestException.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/exceptions/TelegramApiRequestException.java @@ -18,9 +18,9 @@ package org.telegram.telegrambots.meta.exceptions; import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.json.JSONObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.telegram.telegrambots.meta.api.objects.ApiResponse; import org.telegram.telegrambots.meta.api.objects.ResponseParameters; @@ -33,7 +33,7 @@ import java.io.IOException; * Exception thrown when something goes wrong in the api */ public class TelegramApiRequestException extends TelegramApiException { - private static final Logger log = LogManager.getLogger(TelegramApiRequestException.class); + private static final Logger log = LoggerFactory.getLogger(TelegramApiRequestException.class); private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private static final String ERRORDESCRIPTIONFIELD = "description"; @@ -56,7 +56,7 @@ public class TelegramApiRequestException extends TelegramApiException { try { parameters = OBJECT_MAPPER.readValue(object.getJSONObject(PARAMETERSFIELD).toString(), ResponseParameters.class); } catch (IOException e) { - log.fatal(e.getLocalizedMessage(), e); + log.error(e.getLocalizedMessage(), e); } } } diff --git a/telegrambots-spring-boot-starter/src/main/java/org/telegram/telegrambots/starter/TelegramBotInitializer.java b/telegrambots-spring-boot-starter/src/main/java/org/telegram/telegrambots/starter/TelegramBotInitializer.java index 951dc3b8..c0911641 100644 --- a/telegrambots-spring-boot-starter/src/main/java/org/telegram/telegrambots/starter/TelegramBotInitializer.java +++ b/telegrambots-spring-boot-starter/src/main/java/org/telegram/telegrambots/starter/TelegramBotInitializer.java @@ -1,7 +1,7 @@ package org.telegram.telegrambots.starter; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.telegram.telegrambots.meta.TelegramBotsApi; import org.telegram.telegrambots.meta.exceptions.TelegramApiException; @@ -21,7 +21,7 @@ import static java.lang.String.format; * Receives all beand which are #LongPollingBot and #WebhookBot and register them in #TelegramBotsApi. */ public class TelegramBotInitializer implements InitializingBean { - private static final Logger log = LogManager.getLogger(TelegramBotInitializer.class); + private static final Logger log = LoggerFactory.getLogger(TelegramBotInitializer.class); private final TelegramBotsApi telegramBotsApi; private final List longPollingBots; diff --git a/telegrambots/src/main/java/org/telegram/telegrambots/updatesreceivers/DefaultBotSession.java b/telegrambots/src/main/java/org/telegram/telegrambots/updatesreceivers/DefaultBotSession.java index 319e39ac..78a84d8d 100644 --- a/telegrambots/src/main/java/org/telegram/telegrambots/updatesreceivers/DefaultBotSession.java +++ b/telegrambots/src/main/java/org/telegram/telegrambots/updatesreceivers/DefaultBotSession.java @@ -11,9 +11,9 @@ import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.util.EntityUtils; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.json.JSONException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.telegram.telegrambots.meta.ApiConstants; import org.telegram.telegrambots.meta.api.methods.updates.GetUpdates; import org.telegram.telegrambots.meta.api.objects.Update; @@ -40,7 +40,7 @@ import static org.telegram.telegrambots.Constants.SOCKET_TIMEOUT; * Thread to request updates with active wait */ public class DefaultBotSession implements BotSession { - private static final Logger log = LogManager.getLogger(DefaultBotSession.class); + private static final Logger log = LoggerFactory.getLogger(DefaultBotSession.class); private AtomicBoolean running = new AtomicBoolean(false); @@ -207,7 +207,7 @@ public class DefaultBotSession implements BotSession { log.debug(e.getLocalizedMessage(), e); interrupt(); } catch (Exception global) { - log.fatal(global.getLocalizedMessage(), global); + log.error(global.getLocalizedMessage(), global); try { synchronized (lock) { lock.wait(exponentialBackOff.nextBackOffMillis()); @@ -263,7 +263,7 @@ public class DefaultBotSession implements BotSession { } } } catch (SocketException | InvalidObjectException | TelegramApiRequestException e) { - log.fatal(e.getLocalizedMessage(), e); + log.error(e.getLocalizedMessage(), e); } catch (SocketTimeoutException e) { log.info(e.getLocalizedMessage(), e); } catch (InterruptedException e) { @@ -309,7 +309,7 @@ public class DefaultBotSession implements BotSession { log.debug(e.getLocalizedMessage(), e); interrupt(); } catch (Exception e) { - log.fatal(e.getLocalizedMessage(), e); + log.error(e.getLocalizedMessage(), e); } } log.debug("Handler thread has being closed"); diff --git a/telegrambots/src/main/java/org/telegram/telegrambots/updatesreceivers/RestApi.java b/telegrambots/src/main/java/org/telegram/telegrambots/updatesreceivers/RestApi.java index 35fbc7f1..a6b4725f 100644 --- a/telegrambots/src/main/java/org/telegram/telegrambots/updatesreceivers/RestApi.java +++ b/telegrambots/src/main/java/org/telegram/telegrambots/updatesreceivers/RestApi.java @@ -1,7 +1,7 @@ package org.telegram.telegrambots.updatesreceivers; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.telegram.telegrambots.meta.api.methods.BotApiMethod; import org.telegram.telegrambots.meta.api.objects.Update; import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @@ -24,7 +24,7 @@ import java.util.concurrent.ConcurrentHashMap; */ @Path("callback") public class RestApi { - private static final Logger log = LogManager.getLogger(RestApi.class); + private static final Logger log = LoggerFactory.getLogger(RestApi.class); private final ConcurrentHashMap callbacks = new ConcurrentHashMap<>();