Java源码示例:org.apache.logging.log4j.core.layout.PatternSelector

示例1
@Override
public String toSerializable(LogEvent event) {
	PatternSelector selector = getSelector(event);
	final StringBuilder buf = getStringBuilder();
	PatternFormatter[] formatters = selector.getFormatters(event);
	final int len = formatters.length;
	for (int i = 0; i < len; i++) {
		formatters[i].format(event, buf);
	}
	String str = buf.toString();
	return str;
}
 
示例2
private PatternSelector createExceptionSelector(CustomField... customFieldMdcKeyNames) {
	List<String> customFields = customFieldsAdapter.getCustomFieldKeyNames();
	List<String> excludedFields = customFieldsAdapter.getExcludedFieldKeyNames();
	String exceptionPattern = new LayoutPatternBuilder().addBasicApplicationLogs()
			.addContextProperties(excludedFields).addCustomFields(customFields).addStacktraces().build();
	return new MarkerPatternSelector(new PatternMatch[0], exceptionPattern, false, false, config);
}
 
示例3
private PatternSelector getSelector(LogEvent event) {
	if (event.getThrownProxy() != null || event.getThrown() != null) {
		return execptionSelector;
	}
	return markerSelector;
}