Semantic conventions for exceptions in logs
This document defines semantic conventions for recording exceptions on logs emitted through the Logger API.
Recording an exception
Exceptions SHOULD be recorded as attributes on the LogRecord passed to the Logger emit operations. Exceptions MAY be recorded on “logs” or “events” depending on the context.
To encapsulate proper handling of exceptions API authors MAY provide a
constructor, RecordException
method/extension, or similar helper mechanism on
the LogRecord
class/structure or wherever it makes the most sense depending on
the language runtime.
Attributes
The table below indicates which attributes should be added to the LogRecord and their types.
[1] exception.message
: Required if exception.type
is not set, recommended otherwise.
[2] exception.type
: Required if exception.message
is not set, recommended otherwise.
Stacktrace representation
Same as Trace Semantic Conventions for Exceptions - Stacktrace Representation.
Feedback
Was this page helpful?
Thank you. Your feedback is appreciated!
Please let us know how we can improve this page. Your feedback is appreciated!