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

Merge and move Symfony Monolog docs #11534

Merged
merged 4 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions docs/platforms/php/guides/laravel/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,22 @@ return Application::configure(basePath: dirname(__DIR__))
})
->withExceptions(function (Exceptions $exceptions) {
Integration::handles($exceptions);
})->create();
})
->create();
```

Alternatively, you can configure Sentry in your [Laravel Log Channel](usage/#log-channels), allowing you to log `info` and `debug` as well.
Alternatively, you can configure Sentry as a [Laravel Log Channel](usage/#log-channels).

## Configure

Configure the Sentry DSN with this command:


```shell
php artisan sentry:publish --dsn=___PUBLIC_DSN___
```

It creates the config file (`config/sentry.php`) and adds the `DSN` to your `.env` file.


```shell {filename:.env}
SENTRY_LARAVEL_DSN=___PUBLIC_DSN___
```
Expand Down
23 changes: 2 additions & 21 deletions docs/platforms/php/guides/symfony/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ Install the `sentry/sentry-symfony` bundle:
composer require sentry/sentry-symfony
```

If you are using [Monolog](https://github.com/Seldaek/monolog) to report events instead of the typical error listener approach, you need this [additional configuration](integrations/monolog/) to log the errors correctly.

## Configure

Add your DSN to your `.env` file:


```plain {filename:.env}
###> sentry/sentry-symfony ###
SENTRY_DSN="___PUBLIC_DSN___"
Expand All @@ -32,26 +33,6 @@ SENTRY_DSN="___PUBLIC_DSN___"
In order to receive stack trace arguments in your errors, make sure to set `zend.exception_ignore_args: Off` in your php.ini
</Alert>

### Monolog Integration

If you are using [Monolog](https://github.com/Seldaek/monolog) to report events instead of the typical error listener approach, you need this additional configuration to log the errors correctly:

{/* <!-- prettier-ignore --> */}
```yaml {filename:config/packages/sentry.yaml}
sentry:
register_error_listener: false # Disables the ErrorListener to avoid duplicated log in sentry
register_error_handler: false # Disables the ErrorListener, ExceptionListener and FatalErrorListener integrations of the base PHP SDK

monolog:
handlers:
sentry:
type: sentry
level: !php/const Monolog\Logger::ERROR
hub_id: Sentry\State\HubInterface
fill_extra_context: true # Enables sending monolog context to Sentry
process_psr_3_messages: false # Disables the resolution of PSR-3 placeholders in reported messages
```

## Verify

To test that both logger error and exception are correctly sent to sentry.io, you can create the following controller:
Expand Down
6 changes: 5 additions & 1 deletion docs/platforms/php/guides/symfony/integrations/monolog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ description: "Learn how to enable Sentry's Symfony SDK to capture Monolog events
When using [Monolog](https://github.com/Seldaek/monolog) you can configure a [breadcrumb](../../enriching-events/breadcrumbs/) handler to capture Monolog messages as breadcrumbs and a handler that captures messages as events in Sentry.
The breadcrumb handler will not send anything to Sentry directly, it only records breadcrumbs that will be attached to any event or exception sent to Sentry.

```yaml
```yaml {filename:config/packages/sentry.yaml}
sentry:
register_error_listener: false # Disables the ErrorListener to avoid duplicated log in sentry
register_error_handler: false # Disables the ErrorListener, ExceptionListener and FatalErrorListener integrations of the base PHP SDK

services:
# Configure the breadcrumb handler as a service
Sentry\Monolog\BreadcrumbHandler:
Expand Down
Loading