本文整理汇总了Java中org.apache.commons.logging.Log.info方法的典型用法代码示例。如果您正苦于以下问题:Java Log.info方法的具体用法?Java Log.info怎么用?Java Log.info使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.logging.Log
的用法示例。
在下文中一共展示了Log.info方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: logThreadInfo
import org.apache.commons.logging.Log; //导入方法依赖的package包/类
/**
* Log the current thread stacks at INFO level.
* @param log the logger that logs the stack trace
* @param title a descriptive title for the call stacks
* @param minInterval the minimum time from the last
*/
public static void logThreadInfo(Log log,
String title,
long minInterval) {
boolean dumpStack = false;
if (log.isInfoEnabled()) {
synchronized (ReflectionUtils.class) {
long now = Time.now();
if (now - previousLogTime >= minInterval * 1000) {
previousLogTime = now;
dumpStack = true;
}
}
if (dumpStack) {
try {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
printThreadInfo(new PrintStream(buffer, false, "UTF-8"), title);
log.info(buffer.toString(Charset.defaultCharset().name()));
} catch (UnsupportedEncodingException ignored) {
}
}
}
}
示例2: logException
import org.apache.commons.logging.Log; //导入方法依赖的package包/类
@VisibleForTesting
void logException(Log logger, Throwable e, Call call) {
if (exceptionsHandler.isSuppressedLog(e.getClass())) {
return; // Log nothing.
}
final String logMsg = Thread.currentThread().getName() + ", call " + call;
if (exceptionsHandler.isTerseLog(e.getClass())) {
// Don't log the whole stack trace. Way too noisy!
logger.info(logMsg + ": " + e);
} else if (e instanceof RuntimeException || e instanceof Error) {
// These exception types indicate something is probably wrong
// on the server side, as opposed to just a normal exceptional
// result.
logger.warn(logMsg, e);
} else {
logger.info(logMsg, e);
}
}
示例3: executeInternal
import org.apache.commons.logging.Log; //导入方法依赖的package包/类
@Override
protected void executeInternal() throws Throwable
{
String moduleId = super.getModuleId();
String name = super.getName();
Log logger = LogFactory.getLog(moduleId + "." + name);
switch (logLevel)
{
case INFO:
logger.info(message);
break;
case WARN:
logger.warn(message);
break;
case ERROR:
logger.error(message);
break;
}
}
示例4: logThreadInfo
import org.apache.commons.logging.Log; //导入方法依赖的package包/类
/**
* Log the current thread stacks at INFO level.
* @param log the logger that logs the stack trace
* @param title a descriptive title for the call stacks
* @param minInterval the minimum time from the last
*/
public static void logThreadInfo(Log log,
String title,
long minInterval) {
boolean dumpStack = false;
if (log.isInfoEnabled()) {
synchronized (ReflectionUtils.class) {
long now = System.currentTimeMillis();
if (now - previousLogTime >= minInterval * 1000) {
previousLogTime = now;
dumpStack = true;
}
}
if (dumpStack) {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
printThreadInfo(new PrintWriter(buffer), title);
log.info(buffer.toString());
}
}
}
示例5: logThreadInfo
import org.apache.commons.logging.Log; //导入方法依赖的package包/类
/**
* Log the current thread stacks at INFO level.
* @param log the logger that logs the stack trace
* @param title a descriptive title for the call stacks
* @param minInterval the minimum time from the last
*/
public static void logThreadInfo(Log log,
String title,
long minInterval) {
boolean dumpStack = false;
if (log.isInfoEnabled()) {
synchronized (ReflectionUtils.class) {
long now = System.currentTimeMillis();
if (now - previousLogTime >= minInterval * 1000) {
previousLogTime = now;
dumpStack = true;
}
}
if (dumpStack) {
try {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
printThreadInfo(new PrintStream(buffer, false, "UTF-8"), title);
log.info(buffer.toString(Charset.defaultCharset().name()));
} catch (UnsupportedEncodingException ignored) {
log.warn("Could not write thread info about '" + title +
"' due to a string encoding issue.");
}
}
}
}
示例6: displayRetiredJobNotice
import org.apache.commons.logging.Log; //导入方法依赖的package包/类
/**
* Display a notice on the log that the current MapReduce job has
* been retired, and thus Counters are unavailable.
* @param log the Log to display the info to.
*/
protected void displayRetiredJobNotice(Log log) {
log.info("The MapReduce job has already been retired. Performance");
log.info("counters are unavailable. To get this information, ");
log.info("you will need to enable the completed job store on ");
log.info("the jobtracker with:");
log.info("mapreduce.jobtracker.persist.jobstatus.active = true");
log.info("mapreduce.jobtracker.persist.jobstatus.hours = 1");
log.info("A jobtracker restart is required for these settings");
log.info("to take effect.");
}
示例7: auditStarted
import org.apache.commons.logging.Log; //导入方法依赖的package包/类
/** @see com.puppycrawl.tools.checkstyle.api.AuditListener */
public void auditStarted(AuditEvent aEvt)
{
if (mInitialized) {
final Log log = mLogFactory.getInstance(Checker.class);
log.info("Audit started.");
}
}
示例8: auditFinished
import org.apache.commons.logging.Log; //导入方法依赖的package包/类
/** @see com.puppycrawl.tools.checkstyle.api.AuditListener */
public void auditFinished(AuditEvent aEvt)
{
if (mInitialized) {
final Log log = mLogFactory.getInstance(Checker.class);
log.info("Audit finished.");
}
}
示例9: fileStarted
import org.apache.commons.logging.Log; //导入方法依赖的package包/类
/** @see com.puppycrawl.tools.checkstyle.api.AuditListener */
public void fileStarted(AuditEvent aEvt)
{
if (mInitialized) {
final Log log = mLogFactory.getInstance(Checker.class);
log.info("File \"" + aEvt.getFileName() + "\" started.");
}
}
示例10: fileFinished
import org.apache.commons.logging.Log; //导入方法依赖的package包/类
/** @see com.puppycrawl.tools.checkstyle.api.AuditListener */
public void fileFinished(AuditEvent aEvt)
{
if (mInitialized) {
final Log log = mLogFactory.getInstance(Checker.class);
log.info("File \"" + aEvt.getFileName() + "\" finished.");
}
}
示例11: addError
import org.apache.commons.logging.Log; //导入方法依赖的package包/类
/** @see com.puppycrawl.tools.checkstyle.api.AuditListener */
public void addError(AuditEvent aEvt)
{
final SeverityLevel severityLevel = aEvt.getSeverityLevel();
if (mInitialized && !SeverityLevel.IGNORE.equals(severityLevel)) {
final Log log = mLogFactory.getInstance(aEvt.getSourceName());
final String fileName = aEvt.getFileName();
final String message = aEvt.getMessage();
// avoid StringBuffer.expandCapacity
final int bufLen = message.length() + BUFFER_CUSHION;
final StringBuffer sb = new StringBuffer(bufLen);
sb.append("Line: ").append(aEvt.getLine());
if (aEvt.getColumn() > 0) {
sb.append(" Column: ").append(aEvt.getColumn());
}
sb.append(" Message: ").append(message);
if (aEvt.getSeverityLevel().equals(SeverityLevel.WARNING)) {
log.warn(sb.toString());
}
else if (aEvt.getSeverityLevel().equals(SeverityLevel.INFO)) {
log.info(sb.toString());
}
else {
log.error(sb.toString());
}
}
}
示例12: logStorageContents
import org.apache.commons.logging.Log; //导入方法依赖的package包/类
public static void logStorageContents(Log LOG, NNStorage storage) {
LOG.info("current storages and corresponding sizes:");
for (StorageDirectory sd : storage.dirIterable(null)) {
File curDir = sd.getCurrentDir();
LOG.info("In directory " + curDir);
File[] files = curDir.listFiles();
Arrays.sort(files);
for (File f : files) {
LOG.info(" file " + f.getAbsolutePath() + "; len = " + f.length());
}
}
}
示例13: logUpgradePathSQL
import org.apache.commons.logging.Log; //导入方法依赖的package包/类
/**
* Log out the SQL that forms this upgrade path to a logger of your choice.
*
* @param logger the logger to use.
*/
public void logUpgradePathSQL(Log logger) {
if (sql.isEmpty()) {
logger.info("No upgrade statements to be applied");
} else {
logger.info("Upgrade statements:\n" + getUpgradeSqlScript());
}
}
示例14: setServerSideHConnectionRetriesConfig
import org.apache.commons.logging.Log; //导入方法依赖的package包/类
/**
* Changes the configuration to set the number of retries needed when using HConnection
* internally, e.g. for updating catalog tables, etc.
* Call this method before we create any Connections.
* @param c The Configuration instance to set the retries into.
* @param log Used to log what we set in here.
*/
public static void setServerSideHConnectionRetriesConfig(
final Configuration c, final String sn, final Log log) {
// TODO: Fix this. Not all connections from server side should have 10 times the retries.
int hcRetries = c.getInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER,
HConstants.DEFAULT_HBASE_CLIENT_RETRIES_NUMBER);
// Go big. Multiply by 10. If we can't get to meta after this many retries
// then something seriously wrong.
int serversideMultiplier = c.getInt("hbase.client.serverside.retries.multiplier", 10);
int retries = hcRetries * serversideMultiplier;
c.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, retries);
log.info(sn + " server-side HConnection retries=" + retries);
}
示例15: initWebApplicationContext
import org.apache.commons.logging.Log; //导入方法依赖的package包/类
/**
* Initialize Spring's web application context for the given servlet context,
* using the application context provided at construction time, or creating a new one
* according to the "{@link #CONTEXT_CLASS_PARAM contextClass}" and
* "{@link #CONFIG_LOCATION_PARAM contextConfigLocation}" context-params.
* @param servletContext current servlet context
* @return the new WebApplicationContext
* @see #ContextLoader(WebApplicationContext)
* @see #CONTEXT_CLASS_PARAM
* @see #CONFIG_LOCATION_PARAM
*/
public WebApplicationContext initWebApplicationContext(ServletContext servletContext) {
if (servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE) != null) {
throw new IllegalStateException(
"Cannot initialize context because there is already a root application context present - " +
"check whether you have multiple ContextLoader* definitions in your web.xml!");
}
Log logger = LogFactory.getLog(ContextLoader.class);
servletContext.log("Initializing Spring root WebApplicationContext");
if (logger.isInfoEnabled()) {
logger.info("Root WebApplicationContext: initialization started");
}
long startTime = System.currentTimeMillis();
try {
// Store context in local instance variable, to guarantee that
// it is available on ServletContext shutdown.
if (this.context == null) {
this.context = createWebApplicationContext(servletContext);
}
if (this.context instanceof ConfigurableWebApplicationContext) {
ConfigurableWebApplicationContext cwac = (ConfigurableWebApplicationContext) this.context;
if (!cwac.isActive()) {
// The context has not yet been refreshed -> provide services such as
// setting the parent context, setting the application context id, etc
if (cwac.getParent() == null) {
// The context instance was injected without an explicit parent ->
// determine parent for root web application context, if any.
ApplicationContext parent = loadParentContext(servletContext);
cwac.setParent(parent);
}
configureAndRefreshWebApplicationContext(cwac, servletContext);
}
}
servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, this.context);
ClassLoader ccl = Thread.currentThread().getContextClassLoader();
if (ccl == ContextLoader.class.getClassLoader()) {
currentContext = this.context;
}
else if (ccl != null) {
currentContextPerThread.put(ccl, this.context);
}
if (logger.isDebugEnabled()) {
logger.debug("Published root WebApplicationContext as ServletContext attribute with name [" +
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE + "]");
}
if (logger.isInfoEnabled()) {
long elapsedTime = System.currentTimeMillis() - startTime;
logger.info("Root WebApplicationContext: initialization completed in " + elapsedTime + " ms");
}
return this.context;
}
catch (RuntimeException ex) {
logger.error("Context initialization failed", ex);
servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ex);
throw ex;
}
catch (Error err) {
logger.error("Context initialization failed", err);
servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, err);
throw err;
}
}