當前位置: 首頁>>代碼示例>>Java>>正文


Java Logger.fatal方法代碼示例

本文整理匯總了Java中org.apache.log4j.Logger.fatal方法的典型用法代碼示例。如果您正苦於以下問題:Java Logger.fatal方法的具體用法?Java Logger.fatal怎麽用?Java Logger.fatal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.log4j.Logger的用法示例。


在下文中一共展示了Logger.fatal方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import org.apache.log4j.Logger; //導入方法依賴的package包/類
public static void main(String args[])
{
	Logger logger = Logger.getLogger(com.dytech.common.log4j.DailySizeRollingAppender.class);
	do
	{
		logger.info("This is an info statement");
		logger.warn("This is a warning");
		logger.error("This is an error");
		try
		{
			throw new Exception();
		}
		catch( Exception ex )
		{
			logger.fatal("This is fatal", ex);
		}
	}
	while( true );
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:20,代碼來源:DailySizeRollingAppender.java

示例2: main

import org.apache.log4j.Logger; //導入方法依賴的package包/類
public static void main(String args[])
{
	Logger logger = Logger.getLogger(DailySizeRollingAppender.class);
	do
	{
		logger.info("This is an info statement");
		logger.warn("This is a warning");
		logger.error("This is an error");
		try
		{
			throw new Exception();
		}
		catch( Exception ex )
		{
			logger.fatal("This is fatal", ex);
		}
	}
	while( true );
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:20,代碼來源:DailySizeRollingAppender.java

示例3: log

import org.apache.log4j.Logger; //導入方法依賴的package包/類
private void log(LogMessage logMessage, LogLevel level, String loggerName) {
	String logMessageString;
	if (config.getLogInPlainString()) {
		StringBuilder sb = new StringBuilder();
		sb.append("[CID: ").append(logMessage.getCorrelationId());
		if (StringUtils.isNotBlank(logMessage.getCorrelationIdLocal())) {
			sb.append(" CID.Local: ").append(logMessage.getCorrelationIdLocal());
		}
		sb.append("] ").append(logMessage.getMessage());
		String varsInString = LogHelper.variablesToString(logMessage.getVariables(), config.getLogVariableType());
		if (varsInString.length() > 0) {
			sb.append(" [").append(varsInString).append("]");
		}
		if (logMessage.getThrowable() != null) {
			Throwable t = logMessage.getThrowable();
			sb.append("\nException: ").append(ExceptionUtils.getMessage(t)).append(" ")
					.append(ExceptionUtils.getStackTrace(logMessage.getThrowable()));
			sb.append("");
		}
		logMessageString = sb.toString();
	} else {
		TimeZone tz = TimeZone.getTimeZone("UTC");
		DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
		df.setTimeZone(tz);
		logMessage.setTimestamp(df.format(new Date()));
		logMessage.setLevel(level.toString());
		logMessage.setLogger(loggerName);
		logMessage.setThread(Thread.currentThread().toString());
		Gson gson = new GsonBuilder().disableHtmlEscaping().disableHtmlEscaping().create();
		logMessageString = gson.toJson(logMessage);
	}

	Logger logger = LogManager.getLogger(loggerName);
	switch (level) {
	case INFO:
		logger.info(logMessageString);
		break;
	case ERROR:
		logger.error(logMessageString);
		break;
	case FATAL:
		logger.fatal(logMessageString);
		break;
	case DEBUG:
		logger.debug(logMessageString);
		break;
	}
}
 
開發者ID:iac-m,項目名稱:mule-json-logger,代碼行數:49,代碼來源:JsonLogger.java

示例4: logFatalError

import org.apache.log4j.Logger; //導入方法依賴的package包/類
/**
 * Log an error message.
 *
 * @param message --
 *            error message to log.
 */
public void logFatalError(String message) {
    Logger logger = this.getLogger();
    String newMsg = this.enhanceMessage(message);
    countLines(newMsg);
    logger.fatal(newMsg);

}
 
開發者ID:YunlongYang,項目名稱:LightSIP,代碼行數:14,代碼來源:LogWriter.java

示例5: publish

import org.apache.log4j.Logger; //導入方法依賴的package包/類
@Override
public void publish(LogRecord record)
{
	Logger logger = Logger.getLogger(record.getLoggerName());
	Level level = record.getLevel();
	String message = record.getMessage();
	try
	{
		message = MessageFormat.format(record.getMessage(), record.getParameters());
	}
	catch( IllegalArgumentException ignore )
	{
		// message will possibly have placeholder format for its
		// parameters, such as
		// "frog went {0} on a {1} day", "walking", "summer's",
		// If format fails, send message in the raw.
	}
	if( record.getThrown() != null && !Check.isEmpty(record.getThrown().getLocalizedMessage()) )
	{
		message += '\n' + record.getThrown().getLocalizedMessage();
	}

	if( Level.SEVERE.equals(level) )
	{
		logger.fatal(message);
	}
	else if( Level.INFO.equals(level) )
	{
		logger.info(message);
	}
	else if( Level.WARNING.equals(level) )
	{
		logger.warn(message);
	}
	else if( Level.FINE.equals(level) || Level.FINER.equals(level) || Level.FINEST.equals(level) )
	{
		logger.trace(record);
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:40,代碼來源:ReportingServiceImpl.java


注:本文中的org.apache.log4j.Logger.fatal方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。