-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
In the Decoder
class, common fields in log messages are not parsed into the LoggingEvent
unless parsers are defined. e.g.
@SuppressWarnings("serial")
private static final Map<String, FieldCapturer<LoggingEvent>> DECODER_MAP =
new HashMap<String, FieldCapturer<LoggingEvent>>() {{
put(PatternNames.DATE, new DateParser());
put(PatternNames.LEVEL, new LevelParser());
put(PatternNames.MESSAGE, new MessageParser());
//////////////////////////////////////////////////////////////////////////////////////////////////
// NEED TO ADD PARSERS FOR COMMON FIELDS.....e.g.
put(PatternNames.LOGGER_NAME, new LoggerNameParser());
put(PatternNames.THREAD_NAME, new ThreadParser());
// and probably others
//////////////////////////////////////////////////////////////////////////////////////////////////
}};
The LoggerNameParser
and ThreadParser
are faily simple. e.g.
public class ThreadParser implements FieldCapturer<LoggingEvent> {
public static final Logger logger = LoggerFactory.getLogger(LevelParser.class);
@Override
public void captureField(LoggingEvent event, String fieldAsStr, PatternInfo info) {
event.setThreadName(fieldAsStr.trim());
}
}
trim()
is needed - not sure why
Hope this helps
Michael
Metadata
Metadata
Assignees
Labels
No labels