From eb17b86db1848babca0fad8abb32fe7749fee02e Mon Sep 17 00:00:00 2001 From: bergander Date: Wed, 25 Apr 2018 08:55:24 +0200 Subject: [PATCH] Change log level on some messages from info to debug (#44) --- .../session/HazelcastSessionManager.java | 14 ++++++++------ .../session/HazelcastSessionManager.java | 16 +++++++++------- .../session/HazelcastSessionManager.java | 16 +++++++++------- .../session/HazelcastSessionManager.java | 19 +++++++++++-------- 4 files changed, 37 insertions(+), 28 deletions(-) diff --git a/tomcat6/src/main/java/com/hazelcast/session/HazelcastSessionManager.java b/tomcat6/src/main/java/com/hazelcast/session/HazelcastSessionManager.java index 77db3ff..a22e548 100644 --- a/tomcat6/src/main/java/com/hazelcast/session/HazelcastSessionManager.java +++ b/tomcat6/src/main/java/com/hazelcast/session/HazelcastSessionManager.java @@ -125,7 +125,7 @@ public void start() throws LifecycleException { if (getMapName() == null || "default".equals(getMapName())) { Context ctx = (Context) getContainer(); String contextPath = ctx.getServletContext().getContextPath(); - log.info("contextPath:" + contextPath); + log.debug("contextPath: " + contextPath); String mapName; if (contextPath == null || contextPath.equals("/") || contextPath.equals("")) { mapName = "empty_session_replication"; @@ -227,20 +227,20 @@ public void add(Session session) { @Override public Session findSession(String id) throws IOException { - log.info("sessionId:" + id); + log.debug("sessionId: " + id); if (id == null) { return null; } if (!isSticky() || (isSticky() && !sessions.containsKey(id))) { if (isSticky()) { - log.info("Sticky Session is currently enabled." - + "Some failover occured so reading session from Hazelcast map:" + getMapName()); + log.debug("Sticky Session is currently enabled. " + + "Some failover occurred so reading session from Hazelcast map: " + getMapName()); } HazelcastSession hazelcastSession = sessionMap.get(id); if (hazelcastSession == null) { - log.info("No Session found for:" + id); + log.debug("No Session found for: " + id); return null; } @@ -292,7 +292,9 @@ public void commit(Session session) { if (hazelcastSession.isDirty()) { hazelcastSession.setDirty(false); sessionMap.set(session.getId(), hazelcastSession); - log.info("Thread name:" + Thread.currentThread().getName() + " committed key:" + session.getId()); + if (log.isDebugEnabled()) { + log.debug("Thread name: " + Thread.currentThread().getName() + " committed key: " + session.getId()); + } } } diff --git a/tomcat7/src/main/java/com/hazelcast/session/HazelcastSessionManager.java b/tomcat7/src/main/java/com/hazelcast/session/HazelcastSessionManager.java index 4d698f7..031dcb4 100644 --- a/tomcat7/src/main/java/com/hazelcast/session/HazelcastSessionManager.java +++ b/tomcat7/src/main/java/com/hazelcast/session/HazelcastSessionManager.java @@ -101,7 +101,7 @@ public void startInternal() throws LifecycleException { clientConfig.setClassLoader(getContainer().getLoader().getClassLoader()); instance = HazelcastClient.newHazelcastClient(clientConfig); } catch (Exception e) { - log.error("Hazelcast Client could not be created. ", e); + log.error("Hazelcast Client could not be created.", e); throw new LifecycleException(e.getMessage()); } } else if (getHazelcastInstanceName() != null) { @@ -112,7 +112,7 @@ public void startInternal() throws LifecycleException { if (getMapName() == null || "default".equals(getMapName())) { Context ctx = (Context) getContainer(); String contextPath = ctx.getServletContext().getContextPath(); - log.info("contextPath:" + contextPath); + log.debug("contextPath: " + contextPath); String mapName; if (contextPath == null || contextPath.equals("/") || contextPath.equals("")) { mapName = "empty_session_replication"; @@ -226,20 +226,20 @@ public void add(Session session) { @Override public Session findSession(String id) throws IOException { - log.debug("sessionId:" + id); + log.debug("sessionId: " + id); if (id == null) { return null; } if (!isSticky() || (isSticky() && !sessions.containsKey(id))) { if (isSticky()) { - log.info("Sticky Session is currently enabled." - + "Some failover occured so reading session from Hazelcast map:" + getMapName()); + log.debug("Sticky Session is currently enabled. " + + "Some failover occurred so reading session from Hazelcast map: " + getMapName()); } HazelcastSession hazelcastSession = sessionMap.get(id); if (hazelcastSession == null) { - log.info("No Session found for:" + id); + log.debug("No Session found for: " + id); return null; } @@ -291,7 +291,9 @@ public void commit(Session session) { if (hazelcastSession.isDirty()) { hazelcastSession.setDirty(false); sessionMap.set(session.getId(), hazelcastSession); - log.info("Thread name:" + Thread.currentThread().getName() + " committed key:" + session.getId()); + if (log.isDebugEnabled()) { + log.debug("Thread name: " + Thread.currentThread().getName() + " committed key: " + session.getId()); + } } } diff --git a/tomcat8/src/main/java/com/hazelcast/session/HazelcastSessionManager.java b/tomcat8/src/main/java/com/hazelcast/session/HazelcastSessionManager.java index ed811a5..0aeff3c 100644 --- a/tomcat8/src/main/java/com/hazelcast/session/HazelcastSessionManager.java +++ b/tomcat8/src/main/java/com/hazelcast/session/HazelcastSessionManager.java @@ -99,7 +99,7 @@ public void startInternal() throws LifecycleException { clientConfig.setClassLoader(getContext().getLoader().getClassLoader()); instance = HazelcastClient.newHazelcastClient(clientConfig); } catch (Exception e) { - log.error("Hazelcast Client could not be created. ", e); + log.error("Hazelcast Client could not be created.", e); throw new LifecycleException(e.getMessage()); } } else if (getHazelcastInstanceName() != null) { @@ -110,7 +110,7 @@ public void startInternal() throws LifecycleException { if (getMapName() == null || "default".equals(getMapName())) { Context ctx = getContext(); String contextPath = ctx.getServletContext().getContextPath(); - log.info("contextPath:" + contextPath); + log.debug("contextPath: " + contextPath); String mapName; if (contextPath == null || contextPath.equals("/") || contextPath.equals("")) { mapName = "empty_session_replication"; @@ -224,20 +224,20 @@ public void add(Session session) { @Override public Session findSession(String id) throws IOException { - log.debug("sessionId:" + id); + log.debug("sessionId: " + id); if (id == null) { return null; } if (!isSticky() || (isSticky() && !sessions.containsKey(id))) { if (isSticky()) { - log.info("Sticky Session is currently enabled." - + "Some failover occured so reading session from Hazelcast map:" + getMapName()); + log.debug("Sticky Session is currently enabled. " + + "Some failover occurred so reading session from Hazelcast map: " + getMapName()); } HazelcastSession hazelcastSession = sessionMap.get(id); if (hazelcastSession == null) { - log.info("No Session found for:" + id); + log.debug("No Session found for: " + id); return null; } @@ -288,7 +288,9 @@ public void commit(Session session) { if (hazelcastSession.isDirty()) { hazelcastSession.setDirty(false); sessionMap.set(session.getId(), hazelcastSession); - log.info("Thread name:" + Thread.currentThread().getName() + " committed key:" + session.getId()); + if (log.isDebugEnabled()) { + log.debug("Thread name: " + Thread.currentThread().getName() + " committed key: " + session.getId()); + } } } diff --git a/tomcat85/src/main/java/com/hazelcast/session/HazelcastSessionManager.java b/tomcat85/src/main/java/com/hazelcast/session/HazelcastSessionManager.java index 1a76aaf..150ba11 100644 --- a/tomcat85/src/main/java/com/hazelcast/session/HazelcastSessionManager.java +++ b/tomcat85/src/main/java/com/hazelcast/session/HazelcastSessionManager.java @@ -82,7 +82,7 @@ public void startInternal() throws LifecycleException { clientConfig.setClassLoader(getContext().getLoader().getClassLoader()); instance = HazelcastClient.newHazelcastClient(clientConfig); } catch (Exception e) { - log.error("Hazelcast Client could not be created. ", e); + log.error("Hazelcast Client could not be created.", e); throw new LifecycleException(e.getMessage()); } } else if (getHazelcastInstanceName() != null) { @@ -93,7 +93,7 @@ public void startInternal() throws LifecycleException { if (getMapName() == null || "default".equals(getMapName())) { Context ctx = getContext(); String contextPath = ctx.getServletContext().getContextPath(); - log.info("contextPath:" + contextPath); + log.debug("contextPath: " + contextPath); if (contextPath == null || contextPath.equals("/") || contextPath.equals("")) { mapName = "empty_session_replication"; } else { @@ -206,24 +206,25 @@ public void add(Session session) { @Override public Session findSession(String id) throws IOException { - log.debug("Attempting to find sessionId:" + id); + log.debug("Attempting to find sessionId: " + id); + if (id == null) { return null; } if (!isSticky() || (isSticky() && !sessions.containsKey(id))) { if (isSticky()) { - log.info("Sticky Session is currently enabled." - + "Some failover occured so reading session from Hazelcast map:" + getMapName()); + log.debug("Sticky Session is currently enabled. " + + "Some failover occurred so reading session from Hazelcast map: " + getMapName()); } HazelcastSession hazelcastSession = sessionMap.get(id); if (hazelcastSession == null) { - log.info("No Session found for:" + id); + log.debug("No Session found for: " + id); return null; } - log.info("Session found for:" + id); + log.debug("Session found for: " + id); hazelcastSession.access(); hazelcastSession.endAccess(); @@ -272,7 +273,9 @@ public void commit(Session session) { if (hazelcastSession.isDirty()) { hazelcastSession.setDirty(false); sessionMap.set(session.getId(), hazelcastSession); - log.info("Thread name:" + Thread.currentThread().getName() + " committed key:" + session.getId()); + if (log.isDebugEnabled()) { + log.debug("Thread name: " + Thread.currentThread().getName() + " committed key: " + session.getId()); + } } }