mirror of
https://github.com/Seldaek/monolog.git
synced 2026-04-26 08:05:53 +03:00
[GH-ISSUE #590] Fallback Logging #209
Labels
No labels
Bug
Documentation
Feature
Needs Work
Support
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/monolog#209
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @inssein on GitHub (Jun 24, 2015).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/590
Are there any plans to add fallback mechanisms to logging? For example, I plan to use the ElasticSearchHandler, but if for whatever reason it cannot reach the elastic search instance, maybe it could be logged to disk?
I was thinking about perhaps checking the elastic search connection before creating the handler itself, but then this means that it will always open a connection to elastic search. Where as with Monolog, it only opens a connection if there is something to send.
@Seldaek commented on GitHub (Jul 12, 2015):
I think for such specific cases it's better to create a custom handler that takes in two handler and calls the second one if the first one throws.
@Neirda24 commented on GitHub (Jan 22, 2018):
Hi Reopening this issue as it may lead to a feature of some kind.
We had exactly the same problem. So we created a custom handler based of the
WhatFailureGroupHandlerbut added a break if no error was thrown (stop at first succeed)But then we wanted to log the one that had fail because it means that one or more handlers failed and it is never a good sign... We have no idea as to how to implement it.
@masacc commented on GitHub (Jan 22, 2018):
Hi, I'm in the same team than @Neirda24 and here is the solution we have implemented :
Create a FallbackGroupHandler :
src/LogBundle/Handler/FallbackGroupHandler.phpDefine it as a service and inject into it two other handlers that we have previously declared as nested :
src/LogBundle/Resources/config/services/handler.yml:app/config/config_dev.yml:@inverse commented on GitHub (Jul 31, 2019):
@masacc thanks for sharing
@Seldaek Feels like this handler should be in the core. What were your objections against?
@Seldaek commented on GitHub (Aug 15, 2019):
@masacc thanks to @inverse this will be part of 2.0
@inverse commented on GitHub (Aug 15, 2019):
@Seldaek @masacc thanks for the help!