-
-
Notifications
You must be signed in to change notification settings - Fork 232
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
Add support for new handlers #4
Comments
It looks like ChromePHP and Gelf support are now included, so I'd like to add support for the MongoDB handler, but I'm not sure of the best approach. Following the existing handler config would give something like: <?php
// ..... snip ....
case 'mongodb':
$definition->setArguments(array(
new \Mongo($handler['host']),
$handler['database'],
$handler['collection'],
$handler['level'],
$handler['bubble'],
));
break; and allow a config like: monolog:
handlers:
main:
type: stream
path: %kernel.logs_dir%/%kernel.environment%.log
level: debug
mongo:
type: mongodb
host: mongodb://localhost:27017
database: logs
collection: prod
level: debug
bubble: true Creating the Mongo instance there is clearly not the correct way to do it, but I don't know the Service or DI layers well enough to know how to inject it correctly? Also, if I'm using Doctrine MongoDB ODM, it would be nice to be able to reuse the connection thats already been configured for that so that I don't have to maintain two separate configs. Any ideas? |
We could have an You can look at the Gelf config for inspiration: https://github.com/symfony/MonologBundle/blob/master/DependencyInjection/MonologExtension.php#L133-148 |
@Seldaek I've tried to implement this as you described, however I end up with a circular reference. The problem is that Any suggestions how this can be implemented? |
@florianeckerstorfer you have to use a mongo connection with logging disabled if you want to get it from the doctrine connection. |
Is anyone working in mongodb handler? |
I don't think so. I looked into it but it seemed non-trivial to wire up the doctrine mongo stuff etc so I gave up. If you'd like to give it a shot it would be much appreciated. |
I'm wondering if doctrine is really necessary here. We can make the connection with a simple service, or directly with host/port/user/pass params. So you can use the same params for doctrine and monolog configurations, but it's only a matter of taste. I agree with you that it is not trivial to do it with doctrine. |
My concern was duplicating the config if you were already using doctrine, and possibly the overhead of having another connection just for logging. Obviously it would be nicer to re-use the existing config and connection if possible, but I'd rather have a working mongodb handler with extra config than no handler at all. |
Using params you don't have to repeat the literals for database host, and user... So you're true, the only caveat here is the overhead by the existence of another connection. In my case this is needed because we use a server just for logs. |
I have the mongodb basic implementation ready to merge, (without doctrine stuff). |
It looks like the list in the initial description isn't up to date anymore? |
@kingcrunch care to elaborate? I usually try to update it but maybe I missed one. |
@Seldaek I meant the list in this PR (above). I cannot edit that. |
Yes I can update it but what is not up to date exactly? |
I will add here the errbit / airbrake handler if its possible. |
@emgiezet not sure what these have to do with monolog? Are there handlers out there somewhere that I don't know of? |
I've just submitted #92 for Slack support. Also submitted Seldaek/monolog#377 @Seldaek to add support to monolog SlackHandler for the emoji icons used by Slack. Example conifg:
|
Support for the |
Is there any way Rocket.Chat can be added to this list? |
I found a RocketChat Monolog handler that may simplify integration with Symfony: https://github.com/exileed/rocketchat-monolog by @exileed |
I'm working in a RocketChat integration pull request. |
Monolog project don't want add RocketChat support into main project: Seldaek/monolog#1310 |
Define a service for your handler and use the |
This way? https://symfony.com/doc/current/logging/handlers.html
|
yes, exactly. |
Thx so much :_ D I have it working with less problems... |
Support for |
Missing handlers:
The text was updated successfully, but these errors were encountered: