diff --git a/pom.xml b/pom.xml index 3e9832f..b7ea009 100644 --- a/pom.xml +++ b/pom.xml @@ -322,9 +322,9 @@ compile - log4j - log4j - 1.2.17 + org.apache.logging.log4j + log4j-core + 2.15.0 org.postgresql diff --git a/src/main/java/net/socialgamer/cah/CahModule.java b/src/main/java/net/socialgamer/cah/CahModule.java index fe1af8e..bbb7216 100644 --- a/src/main/java/net/socialgamer/cah/CahModule.java +++ b/src/main/java/net/socialgamer/cah/CahModule.java @@ -35,7 +35,8 @@ import javax.servlet.ServletContext; import com.google.common.collect.ImmutableList; import com.google.inject.*; import net.socialgamer.cah.data.GameOptions; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.hibernate.Session; import com.google.common.collect.ImmutableSet; @@ -56,7 +57,7 @@ import net.socialgamer.cah.metrics.UniqueIds; */ public class CahModule extends AbstractModule { - private static final Logger LOG = Logger.getLogger(CahModule.class); + private static final Logger LOG = LogManager.getLogger(CahModule.class); private final Properties properties = new Properties(); diff --git a/src/main/java/net/socialgamer/cah/StartupUtils.java b/src/main/java/net/socialgamer/cah/StartupUtils.java index 28e9b00..6ee4863 100644 --- a/src/main/java/net/socialgamer/cah/StartupUtils.java +++ b/src/main/java/net/socialgamer/cah/StartupUtils.java @@ -25,6 +25,7 @@ package net.socialgamer.cah; import java.io.File; import java.io.FileReader; +import java.net.URI; import java.util.Date; import java.util.Properties; import java.util.concurrent.ScheduledThreadPoolExecutor; @@ -40,8 +41,8 @@ import net.socialgamer.cah.metrics.Metrics; import net.socialgamer.cah.task.BroadcastGameListUpdateTask; import net.socialgamer.cah.task.UserPingTask; -import org.apache.log4j.Logger; -import org.apache.log4j.PropertyConfigurator; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import com.google.inject.Guice; import com.google.inject.Injector; @@ -58,7 +59,7 @@ import com.google.inject.servlet.GuiceServletContextListener; */ public class StartupUtils extends GuiceServletContextListener { - private static final Logger LOG = Logger.getLogger(StartupUtils.class); + private static final Logger LOG = LogManager.getLogger(StartupUtils.class); /** * Context attribute key name for the Guice injector. @@ -167,7 +168,8 @@ public class StartupUtils extends GuiceServletContextListener { public static void reconfigureLogging(final ServletContext context) { LOG.info("Reloading log4j.properties"); - PropertyConfigurator.configure(context.getRealPath("/WEB-INF/log4j.properties")); + URI log4jProps = URI.create(context.getRealPath("/WEB-INF/log4j.properties")); + ((org.apache.logging.log4j.core.LoggerContext) LogManager.getContext(false)).setConfigLocation(log4jProps); } protected Injector getInjector(final ServletContext context) { diff --git a/src/main/java/net/socialgamer/cah/customsets/CustomCardsService.java b/src/main/java/net/socialgamer/cah/customsets/CustomCardsService.java index 10d84e1..bdc79fd 100644 --- a/src/main/java/net/socialgamer/cah/customsets/CustomCardsService.java +++ b/src/main/java/net/socialgamer/cah/customsets/CustomCardsService.java @@ -33,7 +33,8 @@ import net.socialgamer.cah.CahModule.CustomDecksAllowedUrls; import net.socialgamer.cah.CahModule.CustomDecksEnabled; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.lang3.StringEscapeUtils; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.JSONValue; @@ -52,7 +53,7 @@ import java.util.regex.Pattern; public class CustomCardsService { - private static final Logger LOG = Logger.getLogger(CustomCardsService.class); + private static final Logger LOG = LogManager.getLogger(CustomCardsService.class); private static final int GET_TIMEOUT = (int) TimeUnit.SECONDS.toMillis(3); diff --git a/src/main/java/net/socialgamer/cah/data/ConnectedUsers.java b/src/main/java/net/socialgamer/cah/data/ConnectedUsers.java index 01ed78d..efc7883 100644 --- a/src/main/java/net/socialgamer/cah/data/ConnectedUsers.java +++ b/src/main/java/net/socialgamer/cah/data/ConnectedUsers.java @@ -37,7 +37,8 @@ import java.util.stream.Collectors; import javax.annotation.Nullable; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import com.google.inject.Inject; import com.google.inject.Provider; @@ -65,7 +66,7 @@ import net.socialgamer.cah.metrics.Metrics; @Singleton public class ConnectedUsers { - private static final Logger logger = Logger.getLogger(ConnectedUsers.class); + private static final Logger logger = LogManager.getLogger(ConnectedUsers.class); /** * Duration of a ping timeout, in nanoseconds. diff --git a/src/main/java/net/socialgamer/cah/data/Game.java b/src/main/java/net/socialgamer/cah/data/Game.java index f29a68a..dcc5d28 100644 --- a/src/main/java/net/socialgamer/cah/data/Game.java +++ b/src/main/java/net/socialgamer/cah/data/Game.java @@ -34,7 +34,8 @@ import net.socialgamer.cah.data.QueuedMessage.MessageType; import net.socialgamer.cah.metrics.Metrics; import net.socialgamer.cah.task.SafeTimerTask; import org.apache.commons.lang3.StringUtils; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.hibernate.Session; import javax.annotation.Nonnull; @@ -76,7 +77,7 @@ public class Game { * We need 20 * maxPlayers cards. This allows black cards up to "draw 9" to work correctly. */ public final static int MINIMUM_WHITE_CARDS_PER_PLAYER = 20; - private static final Logger logger = Logger.getLogger(Game.class); + private static final Logger logger = LogManager.getLogger(Game.class); /** * Time, in milliseconds, to delay before starting a new round. */ diff --git a/src/main/java/net/socialgamer/cah/data/GameManager.java b/src/main/java/net/socialgamer/cah/data/GameManager.java index bd71635..66e89f8 100644 --- a/src/main/java/net/socialgamer/cah/data/GameManager.java +++ b/src/main/java/net/socialgamer/cah/data/GameManager.java @@ -31,7 +31,8 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import com.google.common.annotations.VisibleForTesting; import com.google.inject.BindingAnnotation; @@ -54,7 +55,7 @@ import net.socialgamer.cah.task.BroadcastGameListUpdateTask; @Singleton @GameId public class GameManager implements Provider { - private static final Logger logger = Logger.getLogger(GameManager.class); + private static final Logger logger = LogManager.getLogger(GameManager.class); private final Provider maxGamesProvider; private final Map games = new TreeMap(); diff --git a/src/main/java/net/socialgamer/cah/data/User.java b/src/main/java/net/socialgamer/cah/data/User.java index fccb9f0..b7bb5b2 100644 --- a/src/main/java/net/socialgamer/cah/data/User.java +++ b/src/main/java/net/socialgamer/cah/data/User.java @@ -30,7 +30,8 @@ import java.util.concurrent.PriorityBlockingQueue; import javax.annotation.Nullable; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; @@ -48,7 +49,7 @@ import net.socialgamer.cah.Constants.Sigil; */ public class User { - private static final Logger LOG = Logger.getLogger(User.class); + private static final Logger LOG = LogManager.getLogger(User.class); private final String nickname; diff --git a/src/main/java/net/socialgamer/cah/handlers/BanHandler.java b/src/main/java/net/socialgamer/cah/handlers/BanHandler.java index f310200..488af0c 100644 --- a/src/main/java/net/socialgamer/cah/handlers/BanHandler.java +++ b/src/main/java/net/socialgamer/cah/handlers/BanHandler.java @@ -44,13 +44,14 @@ import net.socialgamer.cah.data.QueuedMessage; import net.socialgamer.cah.data.QueuedMessage.MessageType; import net.socialgamer.cah.data.User; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import com.google.inject.Inject; public class BanHandler extends Handler { - protected final Logger logger = Logger.getLogger(BanHandler.class); + protected final Logger logger = LogManager.getLogger(BanHandler.class); public static final String OP = AjaxOperation.BAN.toString(); diff --git a/src/main/java/net/socialgamer/cah/handlers/ChatHandler.java b/src/main/java/net/socialgamer/cah/handlers/ChatHandler.java index 5a5ab99..93ccc35 100644 --- a/src/main/java/net/socialgamer/cah/handlers/ChatHandler.java +++ b/src/main/java/net/socialgamer/cah/handlers/ChatHandler.java @@ -28,7 +28,8 @@ import java.util.Map; import javax.servlet.http.HttpSession; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import com.google.inject.Inject; @@ -54,7 +55,7 @@ import net.socialgamer.cah.util.ChatFilter; */ public class ChatHandler extends Handler { - private static final Logger LOG = Logger.getLogger(ChatHandler.class); + private static final Logger LOG = LogManager.getLogger(ChatHandler.class); public static final String OP = AjaxOperation.CHAT.toString(); private final ChatFilter chatFilter; diff --git a/src/main/java/net/socialgamer/cah/handlers/FirstLoadHandler.java b/src/main/java/net/socialgamer/cah/handlers/FirstLoadHandler.java index 98d4066..3208b4b 100644 --- a/src/main/java/net/socialgamer/cah/handlers/FirstLoadHandler.java +++ b/src/main/java/net/socialgamer/cah/handlers/FirstLoadHandler.java @@ -32,7 +32,8 @@ import java.util.Set; import javax.servlet.http.HttpSession; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.hibernate.Session; import org.hibernate.Transaction; @@ -67,7 +68,7 @@ import net.socialgamer.cah.db.PyxCardSet; */ public class FirstLoadHandler extends Handler { - private static final Logger LOG = Logger.getLogger(FirstLoadHandler.class); + private static final Logger LOG = LogManager.getLogger(FirstLoadHandler.class); public static final String OP = AjaxOperation.FIRST_LOAD.toString(); private final Set banList; diff --git a/src/main/java/net/socialgamer/cah/handlers/GameChatHandler.java b/src/main/java/net/socialgamer/cah/handlers/GameChatHandler.java index 4d2b513..3ff6ae8 100644 --- a/src/main/java/net/socialgamer/cah/handlers/GameChatHandler.java +++ b/src/main/java/net/socialgamer/cah/handlers/GameChatHandler.java @@ -28,7 +28,8 @@ import java.util.Map; import javax.servlet.http.HttpSession; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import com.google.inject.Inject; @@ -55,7 +56,7 @@ import net.socialgamer.cah.util.ChatFilter; */ public class GameChatHandler extends GameWithPlayerHandler { - private static final Logger LOG = Logger.getLogger(GameChatHandler.class); + private static final Logger LOG = LogManager.getLogger(GameChatHandler.class); public static final String OP = AjaxOperation.GAME_CHAT.toString(); private final ChatFilter chatFilter; diff --git a/src/main/java/net/socialgamer/cah/handlers/KickHandler.java b/src/main/java/net/socialgamer/cah/handlers/KickHandler.java index a1ef745..7ba5ab3 100644 --- a/src/main/java/net/socialgamer/cah/handlers/KickHandler.java +++ b/src/main/java/net/socialgamer/cah/handlers/KickHandler.java @@ -19,13 +19,14 @@ import net.socialgamer.cah.data.QueuedMessage; import net.socialgamer.cah.data.QueuedMessage.MessageType; import net.socialgamer.cah.data.User; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import com.google.inject.Inject; public class KickHandler extends Handler { - protected final Logger logger = Logger.getLogger(KickHandler.class); + protected final Logger logger = LogManager.getLogger(KickHandler.class); public static final String OP = AjaxOperation.KICK.toString(); diff --git a/src/main/java/net/socialgamer/cah/handlers/RegisterHandler.java b/src/main/java/net/socialgamer/cah/handlers/RegisterHandler.java index 5ee9271..4779a98 100644 --- a/src/main/java/net/socialgamer/cah/handlers/RegisterHandler.java +++ b/src/main/java/net/socialgamer/cah/handlers/RegisterHandler.java @@ -33,7 +33,8 @@ import javax.servlet.http.HttpSession; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpHeaders; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import com.google.inject.Inject; import com.google.inject.Provider; @@ -65,7 +66,7 @@ import net.socialgamer.cah.util.IdCodeMangler; */ public class RegisterHandler extends Handler { - private static final Logger LOG = Logger.getLogger(RegisterHandler.class); + private static final Logger LOG = LogManager.getLogger(RegisterHandler.class); public static final String OP = AjaxOperation.REGISTER.toString(); private static final Pattern VALID_NAME = Pattern.compile("[a-zA-Z_][a-zA-Z0-9_]{2,29}"); diff --git a/src/main/java/net/socialgamer/cah/handlers/StopGameHandler.java b/src/main/java/net/socialgamer/cah/handlers/StopGameHandler.java index 844cd1a..454af24 100644 --- a/src/main/java/net/socialgamer/cah/handlers/StopGameHandler.java +++ b/src/main/java/net/socialgamer/cah/handlers/StopGameHandler.java @@ -37,7 +37,8 @@ import net.socialgamer.cah.data.Game; import net.socialgamer.cah.data.GameManager; import net.socialgamer.cah.data.User; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import com.google.inject.Inject; @@ -47,7 +48,7 @@ import com.google.inject.Inject; */ public class StopGameHandler extends GameWithPlayerHandler { - protected final Logger logger = Logger.getLogger(GameWithPlayerHandler.class); + protected final Logger logger = LogManager.getLogger(GameWithPlayerHandler.class); public static final String OP = AjaxOperation.STOP_GAME.toString(); diff --git a/src/main/java/net/socialgamer/cah/metrics/GeoIP.java b/src/main/java/net/socialgamer/cah/metrics/GeoIP.java index 0ea5528..a3aed2f 100644 --- a/src/main/java/net/socialgamer/cah/metrics/GeoIP.java +++ b/src/main/java/net/socialgamer/cah/metrics/GeoIP.java @@ -29,7 +29,8 @@ import java.net.InetAddress; import java.util.Properties; import org.apache.commons.lang3.StringUtils; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import com.google.inject.Inject; import com.google.inject.Provider; @@ -48,7 +49,7 @@ import com.maxmind.geoip2.model.CityResponse; @Singleton public class GeoIP { - private static final Logger LOG = Logger.getLogger(GeoIP.class); + private static final Logger LOG = LogManager.getLogger(GeoIP.class); private DatabaseReader reader; private boolean initialized = false; diff --git a/src/main/java/net/socialgamer/cah/metrics/KafkaMetrics.java b/src/main/java/net/socialgamer/cah/metrics/KafkaMetrics.java index f36e61c..ad336bf 100644 --- a/src/main/java/net/socialgamer/cah/metrics/KafkaMetrics.java +++ b/src/main/java/net/socialgamer/cah/metrics/KafkaMetrics.java @@ -47,7 +47,8 @@ import org.apache.kafka.common.PartitionInfo; import org.apache.kafka.common.config.SaslConfigs; import org.apache.kafka.common.config.SslConfigs; import org.apache.kafka.common.serialization.StringSerializer; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.json.simple.JSONValue; import com.google.inject.Inject; @@ -73,7 +74,7 @@ public class KafkaMetrics implements Metrics { // 0.1: initial version // 0.2: added cardDealt private static final String metricsVersion = "0.2"; - private static final Logger LOG = Logger.getLogger(KafkaMetrics.class); + private static final Logger LOG = LogManager.getLogger(KafkaMetrics.class); private final ProducerCallback callback = new ProducerCallback(); private final String build; diff --git a/src/main/java/net/socialgamer/cah/metrics/NoOpMetrics.java b/src/main/java/net/socialgamer/cah/metrics/NoOpMetrics.java index c00816e..29309b0 100644 --- a/src/main/java/net/socialgamer/cah/metrics/NoOpMetrics.java +++ b/src/main/java/net/socialgamer/cah/metrics/NoOpMetrics.java @@ -27,7 +27,8 @@ import java.util.Collection; import java.util.List; import java.util.Map; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import com.google.inject.Singleton; import com.maxmind.geoip2.model.CityResponse; @@ -45,7 +46,7 @@ import net.socialgamer.cah.data.WhiteCard; @Singleton public class NoOpMetrics implements Metrics { - private static final Logger LOG = Logger.getLogger(NoOpMetrics.class); + private static final Logger LOG = LogManager.getLogger(NoOpMetrics.class); @Override public void shutdown() { diff --git a/src/main/java/net/socialgamer/cah/metrics/UniqueIds.java b/src/main/java/net/socialgamer/cah/metrics/UniqueIds.java index 3c6e063..0da4677 100644 --- a/src/main/java/net/socialgamer/cah/metrics/UniqueIds.java +++ b/src/main/java/net/socialgamer/cah/metrics/UniqueIds.java @@ -31,7 +31,8 @@ import java.util.concurrent.atomic.AtomicLong; import net.socialgamer.cah.CahModule.ServerStarted; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import com.google.inject.Inject; import com.google.inject.Provider; @@ -51,7 +52,7 @@ import com.google.inject.Singleton; @Singleton public class UniqueIds implements Provider { - private static final Logger LOG = Logger.getLogger(UniqueIds.class); + private static final Logger LOG = LogManager.getLogger(UniqueIds.class); private static final String hostname; diff --git a/src/main/java/net/socialgamer/cah/task/SafeTimerTask.java b/src/main/java/net/socialgamer/cah/task/SafeTimerTask.java index b8ec8e7..3127dff 100644 --- a/src/main/java/net/socialgamer/cah/task/SafeTimerTask.java +++ b/src/main/java/net/socialgamer/cah/task/SafeTimerTask.java @@ -1,11 +1,12 @@ package net.socialgamer.cah.task; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; public abstract class SafeTimerTask implements Runnable { - private static final Logger logger = Logger.getLogger(SafeTimerTask.class); + private static final Logger logger = LogManager.getLogger(SafeTimerTask.class); @Override public final void run() { diff --git a/src/main/java/net/socialgamer/cah/util/ChatFilter.java b/src/main/java/net/socialgamer/cah/util/ChatFilter.java index 87a8956..a9b67db 100644 --- a/src/main/java/net/socialgamer/cah/util/ChatFilter.java +++ b/src/main/java/net/socialgamer/cah/util/ChatFilter.java @@ -35,7 +35,8 @@ import java.util.WeakHashMap; import java.util.concurrent.TimeUnit; import java.util.regex.Pattern; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import com.google.common.collect.ImmutableSet; import com.google.inject.Inject; @@ -51,7 +52,7 @@ import net.socialgamer.cah.data.User; */ @Singleton public class ChatFilter { - private static final Logger LOG = Logger.getLogger(ChatFilter.class); + private static final Logger LOG = LogManager.getLogger(ChatFilter.class); private static final int DEFAULT_CHAT_FLOOD_MESSAGE_COUNT = 4; private static final int DEFAULT_CHAT_FLOOD_TIME_SECONDS = 30; diff --git a/src/main/java/net/socialgamer/cah/util/IdCodeMangler.java b/src/main/java/net/socialgamer/cah/util/IdCodeMangler.java index 839c0f2..b9aed44 100644 --- a/src/main/java/net/socialgamer/cah/util/IdCodeMangler.java +++ b/src/main/java/net/socialgamer/cah/util/IdCodeMangler.java @@ -28,7 +28,8 @@ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Base64; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import com.google.inject.Inject; @@ -36,7 +37,7 @@ import net.socialgamer.cah.CahModule.IdCodeSalt; public class IdCodeMangler { - private static final Logger LOG = Logger.getLogger(IdCodeMangler.class); + private static final Logger LOG = LogManager.getLogger(IdCodeMangler.class); private final String salt; private final Base64.Encoder encoder = Base64.getEncoder();