Java Code Examples for org.apache.commons.logging.LogFactory#getLog()
The following examples show how to use
org.apache.commons.logging.LogFactory#getLog() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UrlRewritingResponseWrapper.java From development with Apache License 2.0 | 6 votes |
/** * Basic constructor. * * pock: For BES we use a new server for every request. We can't determine * this server from the serverChain --> use the server of the request as * parameter (Bug 5487) * * @param response * The response we are wrapping * @param server * The server that was matched * @param ownHostName * String we are rewriting servers to * @throws IOException * When there is a problem with the streams */ public UrlRewritingResponseWrapper(HttpServletResponse response, Server server, String ownHostName, String contextPath, ServerChain serverChain) throws IOException { super(response); this.server = server; this.ownHostName = ownHostName; this.contextPath = contextPath; this.serverChain = serverChain; log = LogFactory.getLog(UrlRewritingResponseWrapper.class); outStream = new UrlRewritingOutputStream(response.getOutputStream(), contextPath, response .getCharacterEncoding()); outWriter = new PrintWriter(outStream); originalWriter = new PrintWriter(response.getOutputStream()); }
Example 2
Source File: TransactionalCache.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Ensures that all properties have been set */ public void afterPropertiesSet() throws Exception { PropertyCheck.mandatory(this, "name", name); PropertyCheck.mandatory(this, "sharedCache", sharedCache); // generate the resource binding key resourceKeyTxnData = RESOURCE_KEY_TXN_DATA + "." + name; // Refine the log category logger = LogFactory.getLog(TransactionalCache.class.getName() + "." + name); isDebugEnabled = logger.isDebugEnabled(); // Assign a 'null' cache if write-through is disabled if (disableSharedCache) { sharedCache = NullCache.getInstance(); } }
Example 3
Source File: Log4JAuditDestination.java From ranger with Apache License 2.0 | 6 votes |
@Override public void init(Properties prop, String propPrefix) { super.init(prop, propPrefix); loggerName = MiscUtil.getStringProperty(props, propPrefix + "." + PROP_LOG4J_LOGGER); if (loggerName == null || loggerName.isEmpty()) { loggerName = DEFAULT_LOGGER_PREFIX + "." + getName(); logger.info("Logger property " + propPrefix + "." + PROP_LOG4J_LOGGER + " was not set. Constructing default=" + loggerName); } logger.info("Logger name for " + getName() + " is " + loggerName); auditLogger = LogFactory.getLog(loggerName); logger.info("Done initializing logger for audit. name=" + getName() + ", loggerName=" + loggerName); }
Example 4
Source File: InitializationUtils.java From elasticsearch-hadoop with Apache License 2.0 | 5 votes |
public static boolean setFieldExtractorIfNotSet(Settings settings, Class<? extends FieldExtractor> clazz, Log log) { if (!StringUtils.hasText(settings.getMappingIdExtractorClassName())) { Log logger = (log != null ? log : LogFactory.getLog(clazz)); String name = clazz.getName(); settings.setProperty(ConfigurationOptions.ES_MAPPING_DEFAULT_EXTRACTOR_CLASS, name); if (logger.isDebugEnabled()) { logger.debug(String.format("Using pre-defined field extractor [%s] as default", settings.getMappingIdExtractorClassName())); } return true; } return false; }
Example 5
Source File: Log4jLoggerServiceImpl.java From gflogger with Apache License 2.0 | 5 votes |
@Override public FormattedGFLogEntry formattedLog(LogLevel level, String categoryName, String pattern, final long appenderMask) { final Map<String, Log4jEntry> map = entries.get(); Log4jEntry entry = map.get(categoryName); if (entry == null){ entry = new Log4jEntry(LogFactory.getLog(categoryName)); map.put(categoryName, entry); } entry.reset(); entry.setPattern(pattern); entry.setLogLevel(level); return entry; }
Example 6
Source File: TransactionalCache.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Public constructor. */ public TransactionalCache() { logger = LogFactory.getLog(TransactionalCache.class); isDebugEnabled = logger.isDebugEnabled(); disableSharedCache = false; isMutable = true; allowEqualsChecks = false; }
Example 7
Source File: InitializationUtils.java From elasticsearch-hadoop with Apache License 2.0 | 5 votes |
public static boolean setUserProviderIfNotSet(Settings settings, Class<? extends UserProvider> clazz, Log log) { if (!StringUtils.hasText(settings.getSecurityUserProviderClass())) { settings.setProperty(ConfigurationOptions.ES_SECURITY_USER_PROVIDER_CLASS, clazz.getName()); Log logger = (log != null ? log : LogFactory.getLog(clazz)); if (logger.isDebugEnabled()) { logger.debug(String.format("Using pre-defined user provider [%s] as default", settings.getSecurityUserProviderClass())); } return true; } return false; }
Example 8
Source File: InitializationUtils.java From elasticsearch-hadoop with Apache License 2.0 | 5 votes |
public static boolean setMetadataExtractorIfNotSet(Settings settings, Class<? extends MetadataExtractor> clazz, Log log) { if (!StringUtils.hasText(settings.getMappingMetadataExtractorClassName())) { Log logger = (log != null ? log : LogFactory.getLog(clazz)); String name = clazz.getName(); settings.setProperty(ConfigurationOptions.ES_MAPPING_METADATA_EXTRACTOR_CLASS, name); if (logger.isDebugEnabled()) { logger.debug(String.format("Using pre-defined metadata extractor [%s] as default", settings.getMappingMetadataExtractorClassName())); } return true; } return false; }
Example 9
Source File: StackTraceUtil.java From steady with Apache License 2.0 | 4 votes |
private static final Log getLog() { if(StackTraceUtil.log==null) StackTraceUtil.log = LogFactory.getLog(StackTraceUtil.class); return StackTraceUtil.log; }
Example 10
Source File: UserController.java From webcurator with Apache License 2.0 | 4 votes |
/** Default Constructor. */ public UserController() { log = LogFactory.getLog(UserController.class); setCommandClass(UserCommand.class); }
Example 11
Source File: HttpRequestLog.java From hadoop-ozone with Apache License 2.0 | 4 votes |
public static RequestLog getRequestLog(String name) { String lookup = SERVER_TO_COMPONENT.get(name); if (lookup != null) { name = lookup; } String loggerName = "http.requests." + name; String appenderName = name + "requestlog"; Log logger = LogFactory.getLog(loggerName); boolean isLog4JLogger; try { isLog4JLogger = logger instanceof Log4JLogger; } catch (NoClassDefFoundError err) { // In some dependent projects, log4j may not even be on the classpath at // runtime, in which case the above instanceof check will throw // NoClassDefFoundError. LOG.debug("Could not load Log4JLogger class", err); isLog4JLogger = false; } if (isLog4JLogger) { Log4JLogger httpLog4JLog = (Log4JLogger) logger; org.apache.log4j.Logger httpLogger = httpLog4JLog.getLogger(); Appender appender = null; try { appender = httpLogger.getAppender(appenderName); } catch (LogConfigurationException e) { LOG.warn("Http request log for {} could not be created", loggerName); throw e; } if (appender == null) { LOG.info("Http request log for {} is not defined", loggerName); return null; } if (appender instanceof HttpRequestLogAppender) { HttpRequestLogAppender requestLogAppender = (HttpRequestLogAppender) appender; AsyncRequestLogWriter logWriter = new AsyncRequestLogWriter(); logWriter.setFilename(requestLogAppender.getFilename()); logWriter.setRetainDays(requestLogAppender.getRetainDays()); return new CustomRequestLog(logWriter, CustomRequestLog.EXTENDED_NCSA_FORMAT); } else { LOG.warn("Jetty request log for {} was of the wrong class", loggerName); return null; } } else { LOG.warn("Jetty request log can only be enabled using Log4j"); return null; } }
Example 12
Source File: Log4JHierarchyInitTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
public void testAddingLog4jProperties() throws Throwable { Log log = LogFactory.getLog(this.getClass()); // We expect DEBUG to be on assertTrue("DEBUG was not enabled for logger " + this.getClass(), log.isDebugEnabled()); }
Example 13
Source File: InTrayController.java From webcurator with Apache License 2.0 | 4 votes |
/** Default Constructor. */ public InTrayController() { log = LogFactory.getLog(InTrayController.class); setCommandClass(InTrayCommand.class); }
Example 14
Source File: SQLDialectFactory.java From pentaho-metadata with GNU Lesser General Public License v2.1 | 4 votes |
/** * private constructor */ private SQLDialectFactory() { logger = LogFactory.getLog( SQLDialectFactory.class ); registerCoreDialects(); loadDialectPlugins(); }
Example 15
Source File: MutablePropertySources.java From spring4-understanding with Apache License 2.0 | 4 votes |
/** * Create a new {@link MutablePropertySources} object. */ public MutablePropertySources() { this.logger = LogFactory.getLog(getClass()); }
Example 16
Source File: AbstractTraceInterceptor.java From spring-analysis-note with MIT License | 2 votes |
/** * Set the name of the logger to use. The name will be passed to the * underlying logger implementation through Commons Logging, getting * interpreted as log category according to the logger's configuration. * <p>This can be specified to not log into the category of a class * (whether this interceptor's class or the class getting called) * but rather into a specific named category. * <p><b>NOTE:</b> Specify either this property or "useDynamicLogger", not both. * @see org.apache.commons.logging.LogFactory#getLog(String) * @see java.util.logging.Logger#getLogger(String) */ public void setLoggerName(String loggerName) { this.defaultLogger = LogFactory.getLog(loggerName); }
Example 17
Source File: ResponseStatusExceptionHandler.java From java-technology-stack with MIT License | 2 votes |
/** * Set the log category for warn logging. * <p>Default is no warn logging. Specify this setting to activate warn * logging into a specific category. * @since 5.1 * @see org.apache.commons.logging.LogFactory#getLog(String) * @see java.util.logging.Logger#getLogger(String) */ public void setWarnLogCategory(String loggerName) { this.warnLogger = LogFactory.getLog(loggerName); }
Example 18
Source File: HttpLogging.java From java-technology-stack with MIT License | 2 votes |
/** * Create a primary logger for the given class and wrap it with a composite * that delegates to it or to the fallback logger * "org.springframework.web.HttpLogging", if the primary is not enabled. * @param primaryLoggerClass the class for the name of the primary logger * @return the resulting composite logger */ public static Log forLogName(Class<?> primaryLoggerClass) { Log primaryLogger = LogFactory.getLog(primaryLoggerClass); return forLog(primaryLogger); }
Example 19
Source File: AbstractTraceInterceptor.java From java-technology-stack with MIT License | 2 votes |
/** * Set whether to use a dynamic logger or a static logger. * Default is a static logger for this trace interceptor. * <p>Used to determine which {@code Log} instance should be used to write * log messages for a particular method invocation: a dynamic one for the * {@code Class} getting called, or a static one for the {@code Class} * of the trace interceptor. * <p><b>NOTE:</b> Specify either this property or "loggerName", not both. * @see #getLoggerForInvocation(org.aopalliance.intercept.MethodInvocation) */ public void setUseDynamicLogger(boolean useDynamicLogger) { // Release default logger if it is not being used. this.defaultLogger = (useDynamicLogger ? null : LogFactory.getLog(getClass())); }
Example 20
Source File: HttpMessageConverterExtractor.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Creates a new instance of the {@code HttpMessageConverterExtractor} with the given response * type and message converters. The given converters must support the response type. */ public HttpMessageConverterExtractor(Type responseType, List<HttpMessageConverter<?>> messageConverters) { this(responseType, messageConverters, LogFactory.getLog(HttpMessageConverterExtractor.class)); }