[GH-ISSUE #363] Retrieving all registered handlers #121

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

Originally created by @auroraeosrose on GitHub (Apr 30, 2014).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/363

Sometimes you want to re-create a Logger you've already created exactly, only with a different name. The issue is you

  1. cannot change the name on a logger
  2. cannot get all the handlers currently associated with the logger (without popping them all off one by one and causing side effects)

The only way around this is evil code that pops everything off and stores it, and pops everything on, or stores handlers in another location in the app every time (which in large apps is obnoxious, especially when your handler sets can be quite disparate or controlled entirely by environment)

Can we possibly get a "getHandlers()" method that just returns the contents of the protected $handlers array? corollary, getProcessors() would be great as well

$copied_logger = new Logger('newname', $old->getHandlers(), $old->getProcessors());

would make my life 200% better ;)

Originally created by @auroraeosrose on GitHub (Apr 30, 2014). Original GitHub issue: https://github.com/Seldaek/monolog/issues/363 Sometimes you want to re-create a Logger you've already created exactly, only with a different name. The issue is you 1. cannot change the name on a logger 2. cannot get all the handlers currently associated with the logger (without popping them all off one by one and causing side effects) The only way around this is evil code that pops everything off and stores it, and pops everything on, or stores handlers in another location in the app every time (which in large apps is obnoxious, especially when your handler sets can be quite disparate or controlled entirely by environment) Can we possibly get a "getHandlers()" method that just returns the contents of the protected $handlers array? corollary, getProcessors() would be great as well $copied_logger = new Logger('newname', $old->getHandlers(), $old->getProcessors()); would make my life 200% better ;)
kerem closed this issue 2026-03-04 02:12:22 +03:00
Author
Owner

@Seldaek commented on GitHub (May 1, 2014):

Makes sense, it's just that nobody asked or needed this before :)

<!-- gh-comment-id:41923414 --> @Seldaek commented on GitHub (May 1, 2014): Makes sense, it's just that nobody asked or needed this before :)
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#121
No description provided.