This is an automated email from the ASF dual-hosted git repository. spolavarapu pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/ranger.git
The following commit(s) were added to refs/heads/master by this push: new bc74cb2 RANGER-2638: Ranger admin Logging improvement bc74cb2 is described below commit bc74cb2467229bb8b1cf89f593547eec00a6480d Author: Sailaja Polavarapu <spolavar...@cloudera.com> AuthorDate: Thu Nov 14 14:44:44 2019 -0800 RANGER-2638: Ranger admin Logging improvement --- .../java/org/apache/ranger/biz/SessionMgr.java | 34 +++++++++++++--------- .../org/apache/ranger/db/XXGlobalStateDao.java | 6 ++-- .../web/filter/RangerKRBAuthenticationFilter.java | 8 +++-- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/security-admin/src/main/java/org/apache/ranger/biz/SessionMgr.java b/security-admin/src/main/java/org/apache/ranger/biz/SessionMgr.java index 4a426b7..ce09c36 100644 --- a/security-admin/src/main/java/org/apache/ranger/biz/SessionMgr.java +++ b/security-admin/src/main/java/org/apache/ranger/biz/SessionMgr.java @@ -180,17 +180,19 @@ public class SessionMgr { resetUserModulePermission(userSession); Calendar cal = Calendar.getInstance(); - if (details != null) { - logger.info("Login Success: loginId=" + currentLoginId - + ", sessionId=" + gjAuthSession.getId() - + ", sessionId=" + details.getSessionId() - + ", requestId=" + details.getRemoteAddress() - + ", epoch=" + cal.getTimeInMillis()); - } else { - logger.info("Login Success: loginId=" + currentLoginId - + ", sessionId=" + gjAuthSession.getId() - + ", details is null" - + ", epoch=" + cal.getTimeInMillis()); + if(logger.isDebugEnabled()) { + if (details != null) { + logger.debug("Login Success: loginId=" + currentLoginId + + ", sessionId=" + gjAuthSession.getId() + + ", sessionId=" + details.getSessionId() + + ", requestId=" + details.getRemoteAddress() + + ", epoch=" + cal.getTimeInMillis()); + } else { + logger.debug("Login Success: loginId=" + currentLoginId + + ", sessionId=" + gjAuthSession.getId() + + ", details is null" + + ", epoch=" + cal.getTimeInMillis()); + } } } @@ -229,7 +231,9 @@ public class SessionMgr { rangerUserPermission.setUserPermissions(userPermissions); rangerUserPermission.setLastUpdatedTime(Calendar.getInstance().getTimeInMillis()); userSession.setRangerUserPermission(rangerUserPermission); - logger.info("UserSession Updated to set new Permissions to User: " + userSession.getLoginId()); + if (logger.isDebugEnabled()) { + logger.debug("UserSession Updated to set new Permissions to User: " + userSession.getLoginId()); + } } else { logger.error("No XUser found with username: " + userSession.getLoginId() + "So Permission is not set for the user"); } @@ -314,7 +318,7 @@ public class SessionMgr { .equalsIgnoreCase(userSession.getXXPortalUser().getLoginId())) { return true; } else { - logger.info( + logger.warn( "loginId doesn't match loginId from HTTPSession. Will create new session. loginId=" + currentLoginId + ", userSession=" + userSession, new Exception()); @@ -442,7 +446,9 @@ public class SessionMgr { logger.error("Error getting user for loginId=" + loginId); return false; } else { - logger.info(loginId+" is a valid user"); + if(logger.isDebugEnabled()) { + logger.debug(loginId + " is a valid user"); + } return true; } diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXGlobalStateDao.java b/security-admin/src/main/java/org/apache/ranger/db/XXGlobalStateDao.java index 38cb1fd..65bb8ed 100644 --- a/security-admin/src/main/java/org/apache/ranger/db/XXGlobalStateDao.java +++ b/security-admin/src/main/java/org/apache/ranger/db/XXGlobalStateDao.java @@ -33,7 +33,7 @@ import java.util.Map; @Service public class XXGlobalStateDao extends BaseDao<XXGlobalState> { - private static final Logger logger = Logger.getLogger(RangerDaoManager.class); + private static final Logger logger = Logger.getLogger(XXGlobalStateDao.class); final static String APP_DATA_ENTRY_ROLE_VERSION = "RangerRoleVersion"; @@ -96,7 +96,9 @@ public class XXGlobalStateDao extends BaseDao<XXGlobalState> { ret = 1L; } } catch (Exception exception) { - logger.warn("Unable to find the role version in Ranger Database"); + if (logger.isDebugEnabled()) { + logger.debug("Unable to find the role version in Ranger Database", exception); + } } return ret; } diff --git a/security-admin/src/main/java/org/apache/ranger/security/web/filter/RangerKRBAuthenticationFilter.java b/security-admin/src/main/java/org/apache/ranger/security/web/filter/RangerKRBAuthenticationFilter.java index b38d9d9..994559e 100644 --- a/security-admin/src/main/java/org/apache/ranger/security/web/filter/RangerKRBAuthenticationFilter.java +++ b/security-admin/src/main/java/org/apache/ranger/security/web/filter/RangerKRBAuthenticationFilter.java @@ -317,7 +317,9 @@ public class RangerKRBAuthenticationFilter extends RangerKrbFilter { } SecurityContextHolder.getContext().setAuthentication(authentication); request.setAttribute("spnegoEnabled", true); - LOG.info("Logged into Ranger as = " + userName); + if(LOG.isDebugEnabled()) { + LOG.debug("Logged into Ranger as = " + userName); + } } filterChain.doFilter(request, response); }else{ @@ -380,7 +382,9 @@ public class RangerKRBAuthenticationFilter extends RangerKrbFilter { authentication = getGrantedAuthority(authentication); SecurityContextHolder.getContext().setAuthentication(authentication); request.setAttribute("spnegoEnabled", true); - LOG.info("Logged into Ranger as = "+userName); + if(LOG.isDebugEnabled()) { + LOG.debug("Logged into Ranger as = " + userName); + } }else{ try{ super.doFilter(request, response, filterChain);