Skip to content

Add structured logging stacktrace hash field - #49793

Closed
GollapudiSrikanth wants to merge 3 commits into
spring-projects:mainfrom
GollapudiSrikanth:srikanthgollapudi-structured-logging-stacktrace-hash-field
Closed

Add structured logging stacktrace hash field#49793
GollapudiSrikanth wants to merge 3 commits into
spring-projects:mainfrom
GollapudiSrikanth:srikanthgollapudi-structured-logging-stacktrace-hash-field

Conversation

@GollapudiSrikanth

Copy link
Copy Markdown
Contributor

Summary

This PR adds support for emitting the stacktrace hash as a separate structured logging field, in addition to the existing inline format.

Details

Currently, when logging.structured.json.stacktrace.include-hashes is enabled, the hash is prefixed inline within the stack_trace field. While this is useful, it makes it harder to filter and group logs based on the hash value.

This change introduces new configuration properties:

logging.structured.stacktrace.hash.generate=inline | as-field
logging.structured.stacktrace.hash.field-name=stack_trace_hash
  • inline preserves the existing behavior (default for backward compatibility)
  • as-field emits the hash as a separate structured field
  • field-name allows customization of the output field name

Backward Compatibility

  • The existing property logging.structured.json.stacktrace.include-hashes is still supported in a deprecated form
  • When set, it maps to the equivalent inline behavior
  • The new properties take precedence if both are configured

Example

With:

logging.structured.stacktrace.hash.generate=as-field

Output:

{
  "stack_trace": "...",
  "stack_trace_hash": "351b6441"
}

Testing

  • Added tests for:
  • Inline mode (existing behavior)
  • As-field mode
  • Custom field name
  • Deprecated property compatibility and precedence

Related Issue

Closes #49639

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 26, 2026
…ta Naga Sai Srikanth Gollapudi <42247688+GollapudiSrikanth@users.noreply.github.com>

Signed-off-by: Venkata Naga Sai Srikanth Gollapudi <42247688+GollapudiSrikanth@users.noreply.github.com>
… Srikanth Gollapudi<42247688+GollapudiSrikanth@users.noreply.github.com>

Signed-off-by: Venkata Naga Sai Srikanth Gollapudi <42247688+GollapudiSrikanth@users.noreply.github.com>
…a Sai Srikanth Gollapudi <42247688+GollapudiSrikanth@users.noreply.github.com>

Signed-off-by: Venkata Naga Sai Srikanth Gollapudi <42247688+GollapudiSrikanth@users.noreply.github.com>
@GollapudiSrikanth
GollapudiSrikanth force-pushed the srikanthgollapudi-structured-logging-stacktrace-hash-field branch from ec8dbfb to 2050463 Compare March 26, 2026 19:09
@GollapudiSrikanth

This comment was marked as resolved.

@snicoll

This comment was marked as resolved.

@snicoll snicoll assigned snicoll and unassigned snicoll Jul 16, 2026
@snicoll

snicoll commented Jul 22, 2026

Copy link
Copy Markdown
Member

Thanks for the PR. I spent quite a bit of time to review and try to adapt it but I am afraid we need to get back to the design and figure out how to integrate the feature. StackTraceHashFieldConfiguration, in particular, looks out of place to me and the change in the 6 constructors does not feel right to me. I'll flag the related issue team-only.

@snicoll snicoll closed this Jul 22, 2026
@snicoll snicoll added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: declined A suggestion or change that we don't feel we should currently apply

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow structured logging include stack trace hashes to be added to separate structured field

3 participants