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

mapToLogData throwing NullPointerException for json log events without a date #528

Closed
matomer opened this issue Jul 15, 2018 · 3 comments
Closed
Labels
Milestone

Comments

@matomer
Copy link

matomer commented Jul 15, 2018

In class pl.otros.logview.parser.json.JsonExtractor, function mapToLogData, every value that is extracted from the json object has a default - except for dateString.

I don't know if this is intended behavior (I think it would be better to use some default date or something), but in any case I think that the expected behavior shouldn't be an NPE - I think it should either be dropped silently or at least a dedicated exception (e.g. "message without date") should be used so that the cause would be clear.

By the way the user has no way of knowing what happens (since NPEs don't get logged in the internal log), so the user doesn't know if or how many log entries were dropped silently.

@matomer
Copy link
Author

matomer commented Jul 15, 2018

Correction: The user actually does have a way of knowing it (in the JSON pattern parser it says "0 events parsed" and when live, the bottom status bar flashes red with some error), but the cause isn't clear.

@otros-systems otros-systems added this to the 1.4.11 milestone Jul 17, 2018
@otros-systems
Copy link
Owner

Thanks for investigating. Log events without date are problematic because OLV have to assume date.
For other log parser I use current time if timestamp is missing. OLV have to do the same for Json log parser.
I was not expecting that log events in Json/XML format will not have date.

otros-systems added a commit that referenced this issue Jul 17, 2018
#530)

Fix NullPointerException whe parsing JSON log files without date #528
@matomer
Copy link
Author

matomer commented Jul 17, 2018

Thanks for investigating

NP :) just thought I'd give a heads up instead of silently fixing it for myself.

BTW about the other issue I opened (about the datetime), I solved it by adding a custom datetime field to the JSON object generated by log4j2 (and a custom json parser that gets the date from that field). The configuration:

      JsonLayout:
        KeyValuePair:
          key: "datetime"
          value: $${date:yyyy-MM-dd'T'HH:mm:ss.SSSZZZZ}

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

No branches or pull requests

2 participants