Skip to content

Add structured logging stacktrace hash field#49793

Open
GollapudiSrikanth wants to merge 3 commits intospring-projects:mainfrom
GollapudiSrikanth:srikanthgollapudi-structured-logging-stacktrace-hash-field
Open

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

Conversation

@GollapudiSrikanth
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

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

2 participants