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

Cannot use the NullHandler with XML configuration #133

Open
v1nc3n4 opened this issue Jun 24, 2015 · 9 comments · May be fixed by #400
Open

Cannot use the NullHandler with XML configuration #133

v1nc3n4 opened this issue Jun 24, 2015 · 9 comments · May be fixed by #400

Comments

@v1nc3n4
Copy link

v1nc3n4 commented Jun 24, 2015

Hi,

I'm working on a Symfony 2 application, and I'd like to temporary disable logging.
I found that adding the NullHandler on top of the configured handlers shall do the job.
Here's my monolog XML configuration:

<monolog:config>
    <monolog:handler name="null_handler" type="null" />
    <monolog:handler name="file_handler" type="stream" level="info" path="%kernel.logs_dir%/%kernel.environment%.log" />
</monolog:config>

However, when I access a web page, this error occured:

InvalidArgumentException in MonologExtension.php line 611:
Invalid handler type "" given for handler "null_handler"

It seems the null type in the XML parameter is treated as a blank string, and I guess there may be an issue in the Configuration class of the bundle.
What is your opinion?

Thanks for your help,
BR

@stof
Copy link
Member

stof commented Jun 24, 2015

It is not treated as an empty string, but as null

@v1nc3n4
Copy link
Author

v1nc3n4 commented Jun 24, 2015

Yes indeed.

@Seldaek
Copy link
Member

Seldaek commented Jun 24, 2015

I don't know if we can do much about this, given XML is string only it will always be normalized after..

@v1nc3n4
Copy link
Author

v1nc3n4 commented Jun 24, 2015

What about changing the key for the NullHandler or renaming it? for instance:

<monolog:config>
    <monolog:handler name="nolog_handler" type="nolog" />
</monolog:config>

@Seldaek
Copy link
Member

Seldaek commented Jun 24, 2015 via email

@jaymecd
Copy link

jaymecd commented Sep 3, 2015

what about BlackHole? faced same issue today.

@lyrixx
Copy link
Member

lyrixx commented May 18, 2019

I would go with null_handler to keep the same semantics.
Do someone want to submit a PR?

@gggeek
Copy link

gggeek commented Mar 29, 2021

null_handler is fine with me, but the fact that the handler never bubbles makes it in fact behave more similar to what I'd expect from a "black hole" (see #399 for more about this issue)

@gggeek
Copy link

gggeek commented Mar 29, 2021

Pr sent: #400

@jderusse jderusse linked a pull request Mar 31, 2021 that will close this issue
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

Successfully merging a pull request may close this issue.

6 participants