Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Allow disabling exception rendering #52777

Closed
@greg0ire

Description

@greg0ire

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions