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


Java Message.getFormat方法代碼示例

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


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

示例1: appendMessage

import org.apache.logging.log4j.message.Message; //導入方法依賴的package包/類
private void appendMessage(final StringBuilder buffer, final LogEvent event) {
    final Message message = event.getMessage();
    final String text = message.getFormat();

    if (text != null && text.length() > 0) {
        buffer.append(" ").append(escapeNewlines(text, escapeNewLine));
    }

    if (exceptionFormatters != null && event.getThrown() != null) {
        final StringBuilder exception = new StringBuilder(LF);
        for (final PatternFormatter formatter : exceptionFormatters) {
            formatter.format(event, exception);
        }
        buffer.append(escapeNewlines(exception.toString(), escapeNewLine));
    }
    if (includeNewLine) {
        buffer.append(LF);
    }
}
 
開發者ID:OuZhencong,項目名稱:log4j2,代碼行數:20,代碼來源:RFC5424Layout.java

示例2: appendMessage

import org.apache.logging.log4j.message.Message; //導入方法依賴的package包/類
private void appendMessage(final StringBuilder buffer, final LogEvent event) {
    final Message message = event.getMessage();
    // This layout formats StructuredDataMessages instead of delegating to the Message itself.
    final String text = (message instanceof StructuredDataMessage || message instanceof MessageCollectionMessage)
            ? message.getFormat() : message.getFormattedMessage();

    if (text != null && text.length() > 0) {
        buffer.append(' ').append(escapeNewlines(text, escapeNewLine));
    }

    if (exceptionFormatters != null && event.getThrown() != null) {
        final StringBuilder exception = new StringBuilder(LF);
        for (final PatternFormatter formatter : exceptionFormatters) {
            formatter.format(event, exception);
        }
        buffer.append(escapeNewlines(exception.toString(), escapeNewLine));
    }
    if (includeNewLine) {
        buffer.append(LF);
    }
}
 
開發者ID:apache,項目名稱:logging-log4j2,代碼行數:22,代碼來源:Rfc5424Layout.java

示例3: rewrite

import org.apache.logging.log4j.message.Message; //導入方法依賴的package包/類
/**
 * Rewrite the event.
 * 
 * @param source
 *            a logging event that may be returned or used to create a new
 *            logging event.
 * @return The LogEvent after rewriting.
 */
       @Override
public LogEvent rewrite(LogEvent source) {
	// get the markers for the log event. If no markers, nothing can be
	// tagged confidential and we can return
	Marker sourceMarker = source.getMarker();
	if (sourceMarker == null)
		return source;

	// get the message. If no message we can return
	final Message msg = source.getMessage();
	if (msg == null || !(msg instanceof ParameterizedMessage))
		return source;

	// get the parameters. If no params we can return
	Object[] params = msg.getParameters();
	if (params == null || params.length == 0)
		return source;

	// check if this event is actually marked as confidential. If not,
	// return
	Log4jMarker eventMarker = new Log4jMarker(sourceMarker);
	if (!eventMarker.contains(SecurityMarkers.CONFIDENTIAL))
		return source;

	// we have a message, parameters, a marker, and it is confidential.
	// Process
	for (int i = 0; i < params.length; i++) {
		params[i] = MASKED_PASSWORD;
	}
	Message outMessage = new ParameterizedMessage(msg.getFormat(), params,
			msg.getThrowable());
	LogEvent output = new Log4jLogEvent(source.getLoggerName(),
			source.getMarker(), source.getLoggerFqcn(), source.getLevel(),
			outMessage, source.getThrown(), source.getContextMap(),
			source.getContextStack(), source.getThreadName(),
			source.getSource(), source.getTimeMillis());

	return output;
}
 
開發者ID:javabeanz,項目名稱:owasp-security-logging,代碼行數:48,代碼來源:MaskingRewritePolicy.java

示例4: filter

import org.apache.logging.log4j.message.Message; //導入方法依賴的package包/類
@Override
public Result filter(final Logger logger, final Level level, final Marker marker, final Message msg,
                     final Throwable t) {
    if (msg == null) {
        return onMismatch;
    }
    final String text = useRawMessage ? msg.getFormat() : msg.getFormattedMessage();
    return filter(text);
}
 
開發者ID:OuZhencong,項目名稱:log4j2,代碼行數:10,代碼來源:RegexFilter.java

示例5: handleLogMessageException

import org.apache.logging.log4j.message.Message; //導入方法依賴的package包/類
private void handleLogMessageException(final Exception exception, final String fqcn, final Message msg) {
    if (exception instanceof LoggingException) {
        throw (LoggingException) exception;
    }
    final String format = msg.getFormat();
    final StringBuilder sb = new StringBuilder(format.length() + 100);
    sb.append(fqcn);
    sb.append(" caught ");
    sb.append(exception.getClass().getName());
    sb.append(" logging ");
    sb.append(msg.getClass().getSimpleName());
    sb.append(": ");
    sb.append(format);
    StatusLogger.getLogger().warn(sb.toString(), exception);
}
 
開發者ID:apache,項目名稱:logging-log4j2,代碼行數:16,代碼來源:AbstractLogger.java

示例6: filter

import org.apache.logging.log4j.message.Message; //導入方法依賴的package包/類
@Override
public Result filter(final Logger logger, final Level level, final Marker marker, final Message msg,
        final Throwable t) {
    if (msg == null) {
        return onMismatch;
    }
    final String text = useRawMessage ? msg.getFormat() : msg.getFormattedMessage();
    return filter(text);
}
 
開發者ID:apache,項目名稱:logging-log4j2,代碼行數:10,代碼來源:RegexFilter.java


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