[GH-ISSUE #1798] How to set other field into the LogRecord for V3 #760

Closed
opened 2026-03-04 02:17:45 +03:00 by kerem · 1 comment
Owner

Originally created by @yankewei on GitHub (Mar 30, 2023).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/1798

Monolog version 1|2|3?
3
Write your question here.
In Monolog version 2, we could kindly call the pushProcessor method to add our custom processor, which gracefully adds some fields to the log. However, in version 3, the processor's callable has to respectfully accept a LogRecord object, and the LogRecord can only have seven keys - "message", "context", "level", "channel", "datetime", and "extra". We cannot set other fields in the LogRecord object. May I kindly ask if you provide an alternative method that allows us to elegantly customize the LogRecord content?

Originally created by @yankewei on GitHub (Mar 30, 2023). Original GitHub issue: https://github.com/Seldaek/monolog/issues/1798 Monolog version 1|2|3? 3 Write your question here. In Monolog version 2, we could kindly call the `pushProcessor` method to add our custom processor, which gracefully adds some fields to the log. However, in version 3, the processor's callable has to respectfully accept a LogRecord object, and the `LogRecord` can only have seven keys - "message", "context", "level", "channel", "datetime", and "extra". We cannot set other fields in the LogRecord object. May I kindly ask if you provide an alternative method that allows us to elegantly customize the `LogRecord` content?
kerem 2026-03-04 02:17:45 +03:00
  • closed this issue
  • added the
    Support
    label
Author
Owner

@Seldaek commented on GitHub (Jun 20, 2023):

processors were always meant to store data in the extra array, which is still available in monolog 3.

<!-- gh-comment-id:1599539791 --> @Seldaek commented on GitHub (Jun 20, 2023): processors were always meant to store data in the extra array, which is still available in monolog 3.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/monolog#760
No description provided.