本文整理匯總了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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}