Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there an option to remove particular handler from the monolog? #369

Closed
PavelPolyakov opened this issue May 16, 2014 · 3 comments
Closed

Comments

@PavelPolyakov
Copy link

Hi,

Let's assume we have the logger with 3 handlers and I want to remove the first one I've pushed.

I found that I can remove handler like this:

Log::getMonolog()->popHandler();

But it would remove the most recent handler.
I can iterate through the handlers using getHandlers(), but when I do

$handler->close();

It doesn't help.

How to remove the one I want?

@Seldaek
Copy link
Owner

Seldaek commented May 19, 2014

Hm yes there is no real way to do this at this point except creating a new Logger and pushing all of them in again except the one you want, or popping until you got the right one and then push again the others.. Not very user friendly I agree, but somehow this is rarely needed except to add a handler temporarily and then remove it again (hence the push/pop).

@PavelPolyakov
Copy link
Author

Thanks for the explanation :)

@Seldaek Seldaek closed this as completed May 20, 2014
@MladenJanjetovic
Copy link

This feature would be useful to speed up work when using Monolog wrapper in some frameworks like Laravel, where i.e. Laravel log file is already assigned by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants