Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decoder needs parsers for Logger name, thread name etc #4

Open
michaeldjcox opened this issue Jun 17, 2013 · 3 comments
Open

Decoder needs parsers for Logger name, thread name etc #4

michaeldjcox opened this issue Jun 17, 2013 · 3 comments

Comments

@michaeldjcox
Copy link

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

@michaeldjcox
Copy link
Author

Any hope of this being sorted?

@tony19
Copy link
Contributor

tony19 commented Jul 19, 2013

I'm a bit preoccupied, but I'll look into it this weekend.

@tony19
Copy link
Contributor

tony19 commented Jul 22, 2013

I've added parsers for the following fields:

  • %caller
  • %class
  • %contextName
  • %line
  • %logger
  • %method
  • %thread

While unit tests exist for these fields, there might be some test cases I've missed. Feel free to create issues for them (and patches/pull-requests would be much appreciated).

The following fields are not [yet] parsed:

  • %BARE (not useful)
  • %exception, %xException, %rootException
  • %mdc
  • %property
  • %replace (not useful)
  • %relative
  • %marker
  • %newline (not useful)
  • (perhaps others)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants