Skip to content

Allow disabling exception rendering #52777

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

Closed
greg0ire opened this issue Nov 28, 2023 · 3 comments · Fixed by #53632
Closed

Allow disabling exception rendering #52777

greg0ire opened this issue Nov 28, 2023 · 3 comments · Fixed by #53632

Comments

@greg0ire
Copy link
Contributor

Description

When using Datadog and Docker, it is recommended to only ever print JSON (for Datadog) to the output (because the output of the main process is the output of the whole container). Datadog documents how to properly configure a Symfony application to fulfill that requirement: https://docs.datadoghq.com/logs/log_collection/php/?tab=phpmonolog

They don't mention it, but you should probably also use --quiet when running a command in production, so that only the json logs show up in the output.

There's one thing that you can't however prevent, and that is the exception rendering done by

public function renderThrowable(\Throwable $e, OutputInterface $output): void
{
$output->writeln('', OutputInterface::VERBOSITY_QUIET);
$this->doRenderThrowable($e, $output);
if (null !== $this->runningCommand) {
$output->writeln(sprintf('<info>%s</info>', OutputFormatter::escape(sprintf($this->runningCommand->getSynopsis(), $this->getName()))), OutputInterface::VERBOSITY_QUIET);
$output->writeln('', OutputInterface::VERBOSITY_QUIET);
}
}

Because of it, what you will see on Datadog is:

  • a properly formatted, CRITICAL datadog line thanks to the monolog configuration
  • one INFO line for each line in the unformatted output.

Example

It might be nice to have something like

framework:
    render_errors: '%kernel.debug%'

to configure this.

@wouterj
Copy link
Member

wouterj commented Dec 18, 2023

I'm facing this as well.

I've proposed a PR to use an env var to disable the output #53126 I think an env var is better for this as it's environment specific (e.g. I still want to see output when running a command locally or in CI)

@petrzivny
Copy link

I would be nice to have this functionality. I haven´t figured a way how to do it and not spoil the logs. It is not only connected to Datadog, but basically any native cloud provider too.

@fabpot fabpot closed this as completed in a18ed8f Sep 21, 2024
@greg0ire
Copy link
Contributor Author

@wouterj thanks for working on this 🙏

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