-
Notifications
You must be signed in to change notification settings - Fork 172
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
How to setup logging for sentry/sentry? #370
Comments
Had a look at the inner workings and it seems the current version is not compatible with getsentry/sentry-php#989. Thoughts? |
For now I fixed it like this in
|
That's the correct way to do it. getsentry/sentry-php#989 is for the 3.0 release, so that's way you can't use it yet. |
In that case, what is the goal of It's quite hacky to override a vendor service. |
@yourithielen Here is a less intrusive way using the kernel with namespace App;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
final class Kernel extends BaseKernel implements CompilerPassInterface
{
use MicroKernelTrait;
public function process(ContainerBuilder $container): void
{
$container->getDefinition(\Sentry\ClientBuilderInterface::class)->addMethodCall(
'setLogger',
[new Reference('logger')]
);
}
} |
That option sets the |
@Jean85 Since the v4 of this bundle, the What is the correct way to set a logger on the sentry client now? Do we have a documentation about this? |
There's a full upgrade doc here: https://github.com/getsentry/sentry-symfony/blob/master/UPGRADE-4.0.md Keep in mind that some stuff may belong to the underlying SDK, which has its upgrade document here: https://github.com/getsentry/sentry-php/blob/master/UPGRADE-3.0.md |
@Jean85 Yes, I did read this documentation first, it says:
But there is not indication about the migration to do, especially for this not documented case. Am I missing something? |
Looking at the code I think there is no easy way, since as you said the builder is not anymore registered as a service mainly because it was not stateless (a mistake) and therefore an instance is not really re-usable to create different clients. What we can definitely do however, and maybe also the best thing, is to expose an option |
@ste93cry You may. However, thanks to the Symfony's autowiring system to automatically bind the Ref: https://symfony.com/doc/current/service_container/autowiring.html Both of them allow two advantages:
My two cents. 👍 |
Using the main logger is not something recommended, because it may create a loop if you use Monolog to report errors to Sentry rather than relying on the custom error handler, which is something we absolutely want to throw away in the next major because it goes into conflict with the built-in one of Symfony. |
How do I setup sentry/sentry logging? I've had some issues sending messages to Sentry (HTTP Error 413 Payload Too Large) but could not find this anywhere in my logs.
I found out that
Sentry\Transport\HttpTransport
uses aPsr\Log\NullLogger
. I'm not using autowiring.What value should I pass to
sentry.options.logger
? I've tried a few but none of them work.The text was updated successfully, but these errors were encountered: