org.apache.logging.log4j.core.layout.PatternSelector Java Examples

The following examples show how to use org.apache.logging.log4j.core.layout.PatternSelector. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JsonPatternLayout.java    From cf-java-logging-support with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #2
Source File: JsonPatternLayout.java    From cf-java-logging-support with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #3
Source File: JsonPatternLayout.java    From cf-java-logging-support with Apache License 2.0 4 votes vote down vote up
private PatternSelector getSelector(LogEvent event) {
	if (event.getThrownProxy() != null || event.getThrown() != null) {
		return execptionSelector;
	}
	return markerSelector;
}