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

Log Json Formatter - LogMessage type #2952

Closed
jeromeky opened this issue Jul 8, 2018 · 3 comments
Closed

Log Json Formatter - LogMessage type #2952

jeromeky opened this issue Jul 8, 2018 · 3 comments

Comments

@jeromeky
Copy link

jeromeky commented Jul 8, 2018

Issue was closed due to inactivity (my bad) - #2580

Also not sure how re-open the original issue.

Hi there,

I'm currently using Payara v4.1.2.173 with the JSON log formatter (https://payara.gitbooks.io/payara-server/documentation/payara-server/logging/json-formatter.html).

However I have an issue with the JSON generated for the LogMessage field.

https://github.com/payara/Payara/blob/master/nucleus/core/logging/src/main/java/fish/payara/enterprise/server/logging/JSONLogFormatter.java

Depending on the log it will generate not the same type of JSON.

i.e

Normal log message:

{
  "_Timestamp": "2018-05-29T13:14:00.378+0000",
  "_Level": "INFO",
  "_Version": "",
  "_LoggerName": "org.mongodb.driver.connection",
  "_ThreadID": "144",
  "_ThreadName": "__ejb-thread-pool3",
  "_TimeMillis": "1527599640378",
  "_LevelValue": "800",
  "_LogMessage": "Opened connection [connectionId{localValue:8, serverValue:10597}] to my-mongo-server:27017"
}

Exception log message:

{
  "_Timestamp": "2018-05-29T13:16:00.683+0000",
  "_Level": "WARNING",
  "_Version": "",
  "_LoggerName": "de.llorenzen.FormatterTest",
  "_ThreadID": "153",
  "_ThreadName": "__ejb-thread-pool12",
  "_TimeMillis": "1527599760683",
  "_LevelValue": "900",
  "_LogMessage": {
    "_Exception": "My exception message",
    "_StackTrace": "com.mongodb.DuplicateKeyException: Write failed with error code 11000 and error message 'E11000 duplicate key error collection: [rest of the stacktrace]"
  }
}

One possible solution would be to add the stacktrace into an other field.

{
  "_Timestamp": "2018-05-29T13:16:00.683+0000",
  "_Level": "WARNING",
  "_Version": "",
  "_LoggerName": "de.llorenzen.FormatterTest",
  "_ThreadID": "153",
  "_ThreadName": "__ejb-thread-pool12",
  "_TimeMillis": "1527599760683",
  "_LevelValue": "900",
  "_LogMessage": "My exception message",
  "_StackTrace": "com.mongodb.DuplicateKeyException: Write failed with error code 11000 and error message 'E11000 duplicate key error collection: [rest of the stacktrace]"
}

Thanks for your help,
Regards,
Jerome.

@svendiedrichsen
Copy link
Contributor

I would vote for a stable JSON structure with fields not being reused.
Without exception:

{
  "_Timestamp": "2018-05-29T13:16:00.683+0000",
  "_Level": "WARNING",
  "_Version": "",
  "_LoggerName": "fish.payara.Fancylogger",
  "_ThreadID": "153",
  "_ThreadName": "__ejb-thread-pool12",
  "_TimeMillis": "1527599760683",
  "_LevelValue": "900",
  "_LogMessage": "Some log message."
  "_Throwable": {}
}

Containing exception:

{
  "_Timestamp": "2018-05-29T13:16:00.683+0000",
  "_Level": "WARNING",
  "_Version": "",
  "_LoggerName": "de.llorenzen.FormatterTest",
  "_ThreadID": "153",
  "_ThreadName": "__ejb-thread-pool12",
  "_TimeMillis": "1527599760683",
  "_LevelValue": "900",
  "_LogMessage": "Some log message."
  "_Throwable": {
    "_Message": "Exception message"
    "_Classname": "java.lang.Exception"
    "_Stacktrace": "Stacktrace-as-string"
  }
}

@smillidge
Copy link
Contributor

anyone fancy doing a PR?

@smillidge smillidge added the Type: Enhancement Label issue as an enhancement request label Jul 10, 2018
@fturizo
Copy link
Contributor

fturizo commented Feb 6, 2020

Since the requester of the ticket fell unresponsive, we'll close this issue. Feel free to raise a new issue by specifying the expected enhancements to implement in a clearer manner if this feature is not present in the current release of Payara Server 5.x

@fturizo fturizo closed this as completed Feb 6, 2020
@fturizo fturizo removed 0:Triaged Type: Enhancement Label issue as an enhancement request labels Feb 6, 2020
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

5 participants