Commit f83e8ee8 by Madhan Neethiraj

ATLAS-1471: logging update (3) to reduce excessive info level logs, reduce…

ATLAS-1471: logging update (3) to reduce excessive info level logs, reduce overheads, switch to sl4j logger
parent 4b8b9e22
...@@ -40,7 +40,7 @@ public class AtlasAuthorizationUtils { ...@@ -40,7 +40,7 @@ public class AtlasAuthorizationUtils {
public static String getApi(String contextPath) { public static String getApi(String contextPath) {
if (isDebugEnabled) { if (isDebugEnabled) {
LOG.debug("==> getApi from {}", contextPath); LOG.debug("==> getApi({})", contextPath);
} }
if (contextPath.startsWith(BASE_URL)) { if (contextPath.startsWith(BASE_URL)) {
contextPath = contextPath.substring(BASE_URL.length()); contextPath = contextPath.substring(BASE_URL.length());
...@@ -56,7 +56,11 @@ public class AtlasAuthorizationUtils { ...@@ -56,7 +56,11 @@ public class AtlasAuthorizationUtils {
if(Pattern.matches("v\\d", api)) { if(Pattern.matches("v\\d", api)) {
api = split[1]; api = split[1];
} }
LOG.info("Now returning API : "+api);
if (isDebugEnabled) {
LOG.debug("<== getApi({}): {}", contextPath, api);
}
return api; return api;
} }
......
...@@ -26,18 +26,18 @@ import java.util.ArrayList; ...@@ -26,18 +26,18 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.apache.log4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class FileReaderUtil { public class FileReaderUtil {
private static Logger LOG = Logger.getLogger(FileReaderUtil.class); private static Logger LOG = LoggerFactory.getLogger(FileReaderUtil.class);
private static boolean isDebugEnabled = LOG.isDebugEnabled(); private static boolean isDebugEnabled = LOG.isDebugEnabled();
public static List<String> readFile(String path) throws IOException { public static List<String> readFile(String path) throws IOException {
if (isDebugEnabled) { if (isDebugEnabled) {
LOG.debug("==> FileReaderUtil readFile"); LOG.debug("==> FileReaderUtil readFile({})", path);
} }
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
LOG.info("reading the file" + path);
List<String> fileLines = Files.readAllLines(Paths.get(path), Charset.forName("UTF-8")); List<String> fileLines = Files.readAllLines(Paths.get(path), Charset.forName("UTF-8"));
if (fileLines != null) { if (fileLines != null) {
for (String line : fileLines) { for (String line : fileLines) {
...@@ -47,7 +47,7 @@ public class FileReaderUtil { ...@@ -47,7 +47,7 @@ public class FileReaderUtil {
} }
if (isDebugEnabled) { if (isDebugEnabled) {
LOG.debug("<== FileReaderUtil readFile"); LOG.debug("<== FileReaderUtil readFile({})", path);
LOG.debug("Policies read :: " + list); LOG.debug("Policies read :: " + list);
} }
......
...@@ -43,7 +43,10 @@ public class PolicyUtil { ...@@ -43,7 +43,10 @@ public class PolicyUtil {
// Iterate over the list of policies to create map // Iterate over the list of policies to create map
for (PolicyDef policyDef : policyDefList) { for (PolicyDef policyDef : policyDefList) {
LOG.info("Processing policy def : {}", policyDef); if (LOG.isDebugEnabled()) {
LOG.debug("Processing policy def : {}", policyDef);
}
Map<String, List<AtlasActionTypes>> principalMap = Map<String, List<AtlasActionTypes>> principalMap =
principalType.equals(SimpleAtlasAuthorizer.AtlasAccessorTypes.USER) ? policyDef.getUsers() : policyDef principalType.equals(SimpleAtlasAuthorizer.AtlasAccessorTypes.USER) ? policyDef.getUsers() : policyDef
.getGroups(); .getGroups();
...@@ -88,7 +91,10 @@ public class PolicyUtil { ...@@ -88,7 +91,10 @@ public class PolicyUtil {
userResourceList.put(type, resourceList); userResourceList.put(type, resourceList);
} }
userReadMap.put(username, userResourceList); userReadMap.put(username, userResourceList);
LOG.info("userReadMap {}", userReadMap);
if (LOG.isDebugEnabled()) {
LOG.debug("userReadMap {}", userReadMap);
}
} }
} }
if (isDebugEnabled) { if (isDebugEnabled) {
......
...@@ -24,7 +24,8 @@ import java.util.List; ...@@ -24,7 +24,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import org.apache.log4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
...@@ -33,7 +34,7 @@ import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; ...@@ -33,7 +34,7 @@ import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
*/ */
public final class PropertiesUtil extends PropertyPlaceholderConfigurer { public final class PropertiesUtil extends PropertyPlaceholderConfigurer {
private static Map<String, String> propertiesMap = new HashMap<>(); private static Map<String, String> propertiesMap = new HashMap<>();
private static Logger logger = Logger.getLogger(PropertiesUtil.class); private static Logger logger = LoggerFactory.getLogger(PropertiesUtil.class);
protected List<String> xmlPropertyConfigurer = new ArrayList<>(); protected List<String> xmlPropertyConfigurer = new ArrayList<>();
private PropertiesUtil() { private PropertiesUtil() {
......
...@@ -25,7 +25,8 @@ import java.util.Properties; ...@@ -25,7 +25,8 @@ import java.util.Properties;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.log4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.DefaultPropertiesPersister; import org.springframework.util.DefaultPropertiesPersister;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
...@@ -35,7 +36,7 @@ import org.w3c.dom.NodeList; ...@@ -35,7 +36,7 @@ import org.w3c.dom.NodeList;
* Util class for XMLProperties. * Util class for XMLProperties.
*/ */
public class XMLPropertiesUtil extends DefaultPropertiesPersister { public class XMLPropertiesUtil extends DefaultPropertiesPersister {
private static Logger logger = Logger.getLogger(XMLPropertiesUtil.class); private static Logger logger = LoggerFactory.getLogger(XMLPropertiesUtil.class);
public XMLPropertiesUtil() { public XMLPropertiesUtil() {
} }
......
...@@ -51,7 +51,11 @@ public class GraphTransactionInterceptor implements MethodInterceptor { ...@@ -51,7 +51,11 @@ public class GraphTransactionInterceptor implements MethodInterceptor {
Object response = invocation.proceed(); Object response = invocation.proceed();
graph.commit(); graph.commit();
isSuccess = true; isSuccess = true;
LOG.info("graph commit");
if (LOG.isDebugEnabled()) {
LOG.debug("graph commit");
}
return response; return response;
} catch (Throwable t) { } catch (Throwable t) {
if (logException(t)) { if (logException(t)) {
......
...@@ -121,7 +121,10 @@ public class HBaseBasedAuditRepository implements Service, EntityAuditRepository ...@@ -121,7 +121,10 @@ public class HBaseBasedAuditRepository implements Service, EntityAuditRepository
* @throws AtlasException * @throws AtlasException
*/ */
public void putEvents(List<EntityAuditEvent> events) throws AtlasException { public void putEvents(List<EntityAuditEvent> events) throws AtlasException {
LOG.info("Putting {} events", events.size()); if (LOG.isDebugEnabled()) {
LOG.debug("Putting {} events", events.size());
}
Table table = null; Table table = null;
try { try {
table = connection.getTable(tableName); table = connection.getTable(tableName);
...@@ -168,7 +171,10 @@ public class HBaseBasedAuditRepository implements Service, EntityAuditRepository ...@@ -168,7 +171,10 @@ public class HBaseBasedAuditRepository implements Service, EntityAuditRepository
*/ */
public List<EntityAuditEvent> listEvents(String entityId, String startKey, short n) public List<EntityAuditEvent> listEvents(String entityId, String startKey, short n)
throws AtlasException { throws AtlasException {
LOG.info("Listing events for entity id {}, starting timestamp {}, #records {}", entityId, startKey, n); if (LOG.isDebugEnabled()) {
LOG.debug("Listing events for entity id {}, starting timestamp {}, #records {}", entityId, startKey, n);
}
Table table = null; Table table = null;
ResultScanner scanner = null; ResultScanner scanner = null;
try { try {
...@@ -216,7 +222,11 @@ public class HBaseBasedAuditRepository implements Service, EntityAuditRepository ...@@ -216,7 +222,11 @@ public class HBaseBasedAuditRepository implements Service, EntityAuditRepository
} }
events.add(event); events.add(event);
} }
LOG.info("Got events for entity id {}, starting timestamp {}, #records {}", entityId, startKey, events.size());
if (LOG.isDebugEnabled()) {
LOG.debug("Got events for entity id {}, starting timestamp {}, #records {}", entityId, startKey, events.size());
}
return events; return events;
} catch (IOException e) { } catch (IOException e) {
throw new AtlasException(e); throw new AtlasException(e);
......
...@@ -34,7 +34,8 @@ import javax.servlet.ServletResponse; ...@@ -34,7 +34,8 @@ import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.atlas.ApplicationProperties; import org.apache.atlas.ApplicationProperties;
import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasException;
import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.Configuration;
...@@ -42,7 +43,7 @@ import org.codehaus.jackson.map.ObjectMapper; ...@@ -42,7 +43,7 @@ import org.codehaus.jackson.map.ObjectMapper;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
public class AtlasCSRFPreventionFilter implements Filter { public class AtlasCSRFPreventionFilter implements Filter {
private static final Logger LOG = Logger.getLogger(AtlasCSRFPreventionFilter.class); private static final Logger LOG = LoggerFactory.getLogger(AtlasCSRFPreventionFilter.class);
private static Configuration configuration; private static Configuration configuration;
static { static {
......
...@@ -27,7 +27,8 @@ import org.apache.atlas.ApplicationProperties; ...@@ -27,7 +27,8 @@ import org.apache.atlas.ApplicationProperties;
import org.apache.atlas.web.model.User; import org.apache.atlas.web.model.User;
import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationConverter; import org.apache.commons.configuration.ConfigurationConverter;
import org.apache.log4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException; import org.springframework.security.core.AuthenticationException;
...@@ -39,8 +40,7 @@ import org.springframework.stereotype.Component; ...@@ -39,8 +40,7 @@ import org.springframework.stereotype.Component;
@Component @Component
public class AtlasADAuthenticationProvider extends public class AtlasADAuthenticationProvider extends
AtlasAbstractAuthenticationProvider { AtlasAbstractAuthenticationProvider {
private static Logger LOG = Logger private static Logger LOG = LoggerFactory.getLogger(AtlasADAuthenticationProvider.class);
.getLogger(AtlasADAuthenticationProvider.class);
private String adURL; private String adURL;
private String adDomain; private String adDomain;
......
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
package org.apache.atlas.web.security; package org.apache.atlas.web.security;
import org.apache.log4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.ObjectMapper;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
import org.springframework.security.core.AuthenticationException; import org.springframework.security.core.AuthenticationException;
...@@ -32,7 +33,7 @@ import java.io.IOException; ...@@ -32,7 +33,7 @@ import java.io.IOException;
public class AtlasAuthenticationFailureHandler implements AuthenticationFailureHandler { public class AtlasAuthenticationFailureHandler implements AuthenticationFailureHandler {
private static Logger LOG = Logger.getLogger(AtlasAuthenticationFailureHandler.class); private static Logger LOG = LoggerFactory.getLogger(AtlasAuthenticationFailureHandler.class);
@Override @Override
public void onAuthenticationFailure(HttpServletRequest httpServletRequest, HttpServletResponse response, public void onAuthenticationFailure(HttpServletRequest httpServletRequest, HttpServletResponse response,
......
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
package org.apache.atlas.web.security; package org.apache.atlas.web.security;
import org.apache.log4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.ObjectMapper;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
...@@ -32,7 +33,7 @@ import java.io.IOException; ...@@ -32,7 +33,7 @@ import java.io.IOException;
public class AtlasAuthenticationSuccessHandler implements AuthenticationSuccessHandler { public class AtlasAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
private static Logger LOG = Logger.getLogger(AuthenticationSuccessHandler.class); private static Logger LOG = LoggerFactory.getLogger(AuthenticationSuccessHandler.class);
@Override @Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
Authentication authentication) throws IOException, ServletException { Authentication authentication) throws IOException, ServletException {
......
...@@ -19,7 +19,8 @@ package org.apache.atlas.web.security; ...@@ -19,7 +19,8 @@ package org.apache.atlas.web.security;
import java.util.Collection; import java.util.Collection;
import org.apache.atlas.web.dao.UserDao; import org.apache.atlas.web.dao.UserDao;
import org.apache.log4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.BadCredentialsException; import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
...@@ -34,7 +35,7 @@ import org.springframework.stereotype.Component; ...@@ -34,7 +35,7 @@ import org.springframework.stereotype.Component;
@Component @Component
public class AtlasFileAuthenticationProvider extends AtlasAbstractAuthenticationProvider { public class AtlasFileAuthenticationProvider extends AtlasAbstractAuthenticationProvider {
private static Logger logger = Logger.getLogger(AtlasFileAuthenticationProvider.class); private static Logger logger = LoggerFactory.getLogger(AtlasFileAuthenticationProvider.class);
@Autowired @Autowired
private UserDetailsService userDetailsService; private UserDetailsService userDetailsService;
......
...@@ -25,7 +25,8 @@ import org.apache.atlas.ApplicationProperties; ...@@ -25,7 +25,8 @@ import org.apache.atlas.ApplicationProperties;
import org.apache.atlas.web.model.User; import org.apache.atlas.web.model.User;
import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationConverter; import org.apache.commons.configuration.ConfigurationConverter;
import org.apache.log4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ldap.core.support.LdapContextSource; import org.springframework.ldap.core.support.LdapContextSource;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
...@@ -42,8 +43,7 @@ import org.springframework.stereotype.Component; ...@@ -42,8 +43,7 @@ import org.springframework.stereotype.Component;
@Component @Component
public class AtlasLdapAuthenticationProvider extends public class AtlasLdapAuthenticationProvider extends
AtlasAbstractAuthenticationProvider { AtlasAbstractAuthenticationProvider {
private static Logger LOG = Logger private static Logger LOG = LoggerFactory.getLogger(AtlasLdapAuthenticationProvider.class);
.getLogger(AtlasLdapAuthenticationProvider.class);
private String ldapURL; private String ldapURL;
private String ldapUserDNPattern; private String ldapUserDNPattern;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment