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

Add log level for JVM logs #92382

Merged
merged 3 commits into from
Jan 10, 2023

Conversation

danielmitterdorfer
Copy link
Member

@danielmitterdorfer danielmitterdorfer commented Dec 15, 2022

With this commit we specify level in JVM logs. level helps to filter more severe messages from mere debugging messages in logs and with this change we are able to use it also for JVM logs.

Here are a few example lines:

Before:

[2022-12-15T06:19:16.936+0000][15181][gc,start    ] GC(0) Pause Young (Normal) (G1 Evacuation Pause)

After:

[2022-12-15T06:22:27.932+0000][16320][info][gc,start    ] GC(0) Pause Young (Normal) (G1 Evacuation Pause)
[2022-12-15T06:22:27.932+0000][16320][debug][gc,age      ] GC(0) Desired survivor size 14680064 bytes, new threshold 15 (max threshold 15)
[2022-12-15T06:22:27.935+0000][16320][info ][gc,phases   ] GC(0)   Pre Evacuate Collection Set: 0.1ms
[2022-12-15T06:22:27.935+0000][16320][trace][gc,age      ] GC(0) Age table with threshold 15 (max threshold 15)

Notice how the log level might have trailing spaces.

See also
https://docs.oracle.com/en/java/javase/19/docs/specs/man/java.html#xlog-tags-and-levels for the available log levels.

With this commit we specify `level` in JVM logs. `level` helps to filter
more severe messages from mere debugging messages in logs and with this
change we are able to use it also for JVM logs.

Here are a few example lines:

Before:

```
[2022-12-15T06:19:16.936+0000][15181][gc,start    ] GC(0) Pause Young (Normal) (G1 Evacuation Pause)
```

After:

```
[2022-12-15T06:22:27.932+0000][16320][info][gc,start    ] GC(0) Pause Young (Normal) (G1 Evacuation Pause)
[2022-12-15T06:22:27.932+0000][16320][debug][gc,age      ] GC(0) Desired survivor size 14680064 bytes, new threshold 15 (max threshold 15)
[2022-12-15T06:22:27.935+0000][16320][info ][gc,phases   ] GC(0)   Pre Evacuate Collection Set: 0.1ms
[2022-12-15T06:22:27.935+0000][16320][trace][gc,age      ] GC(0) Age table with threshold 15 (max threshold 15)
```

Notice, that the log level might have trailing spaces.

See also
https://docs.oracle.com/en/java/javase/19/docs/specs/man/java.html#xlog-tags-and-levels
for the available log levels.
@github-actions
Copy link
Contributor

Documentation preview:

@elasticsearchmachine elasticsearchmachine added the Team:Core/Infra Meta label for core/infra team label Dec 15, 2022
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@elasticsearchmachine
Copy link
Collaborator

Hi @danielmitterdorfer, I've created a changelog YAML for you.

@danielmitterdorfer
Copy link
Member Author

Some more notes:

  • I did not categorize this as a breaking change as it concerns log output and we don't document the specific output format.
  • I changed a few places that were not strictly necessary but it felt more consistent.

Copy link
Contributor

@grcevski grcevski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

danielmitterdorfer added a commit to danielmitterdorfer/beats that referenced this pull request Jan 3, 2023
Elasticsearch will add a log level to its JVM logs to allow users to
help them detect errors / warnings more easily. With this commit we
detect this new field if present and continue to recognize the prior log
format without a log level.

Relates elastic/elasticsearch#92382
Closes elastic#34054
@danielmitterdorfer
Copy link
Member Author

Thanks for the review! Just fyi: I'm waiting to merge this PR until elastic/beats#34159 is merged so Beats can recognize the new field.

leehinman pushed a commit to elastic/beats that referenced this pull request Jan 9, 2023
* Recognize log level in Elasticsearch JVM logs

Elasticsearch will add a log level to its JVM logs to allow users to
help them detect errors / warnings more easily. With this commit we
detect this new field if present and continue to recognize the prior log
format without a log level.

Relates elastic/elasticsearch#92382
Closes #34054
@danielmitterdorfer danielmitterdorfer merged commit 8fc2d6a into elastic:main Jan 10, 2023
@danielmitterdorfer danielmitterdorfer deleted the gc-log-level branch January 10, 2023 06:58
chrisberkhout pushed a commit to elastic/beats that referenced this pull request Jun 1, 2023
* Recognize log level in Elasticsearch JVM logs

Elasticsearch will add a log level to its JVM logs to allow users to
help them detect errors / warnings more easily. With this commit we
detect this new field if present and continue to recognize the prior log
format without a log level.

Relates elastic/elasticsearch#92382
Closes #34054
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Core Core issues without another label >enhancement Team:Core/Infra Meta label for core/infra team v8.7.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants