Skip to content

Commit 97884d4

Browse files
authored
Merge and move Symfony Monolog docs (#11534)
1 parent 805e7eb commit 97884d4

File tree

3 files changed

+14
-28
lines changed

3 files changed

+14
-28
lines changed

docs/platforms/php/guides/laravel/index.mdx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,22 @@ return Application::configure(basePath: dirname(__DIR__))
4141
})
4242
->withExceptions(function (Exceptions $exceptions) {
4343
Integration::handles($exceptions);
44-
})->create();
44+
})
45+
->create();
4546
```
4647

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

4950
## Configure
5051

5152
Configure the Sentry DSN with this command:
5253

53-
5454
```shell
5555
php artisan sentry:publish --dsn=___PUBLIC_DSN___
5656
```
5757

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

60-
6160
```shell {filename:.env}
6261
SENTRY_LARAVEL_DSN=___PUBLIC_DSN___
6362
```

docs/platforms/php/guides/symfony/index.mdx

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ Install the `sentry/sentry-symfony` bundle:
1717
composer require sentry/sentry-symfony
1818
```
1919

20+
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.
21+
2022
## Configure
2123

2224
Add your DSN to your `.env` file:
2325

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

35-
### Monolog Integration
36-
37-
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:
38-
39-
{/* <!-- prettier-ignore --> */}
40-
```yaml {filename:config/packages/sentry.yaml}
41-
sentry:
42-
register_error_listener: false # Disables the ErrorListener to avoid duplicated log in sentry
43-
register_error_handler: false # Disables the ErrorListener, ExceptionListener and FatalErrorListener integrations of the base PHP SDK
44-
45-
monolog:
46-
handlers:
47-
sentry:
48-
type: sentry
49-
level: !php/const Monolog\Logger::ERROR
50-
hub_id: Sentry\State\HubInterface
51-
fill_extra_context: true # Enables sending monolog context to Sentry
52-
process_psr_3_messages: false # Disables the resolution of PSR-3 placeholders in reported messages
53-
```
54-
5536
## Verify
5637

5738
To test that both logger error and exception are correctly sent to sentry.io, you can create the following controller:

docs/platforms/php/guides/symfony/integrations/monolog.mdx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,21 @@ description: "Learn how to enable Sentry's Symfony SDK to capture Monolog events
66
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.
77
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.
88

9-
```yaml
9+
```yaml {filename:config/packages/sentry.yaml}
10+
sentry:
11+
register_error_listener: false # Disables the ErrorListener to avoid duplicated log in sentry
12+
register_error_handler: false # Disables the ErrorListener, ExceptionListener and FatalErrorListener integrations of the base PHP SDK
13+
1014
services:
11-
# Configure the breadcrumb handler as a service
15+
# (Optionally) Configure the breadcrumb handler as a service (needed for the breadcrumb Monolog handler)
1216
Sentry\Monolog\BreadcrumbHandler:
1317
arguments:
1418
- '@Sentry\State\HubInterface'
1519
- !php/const Monolog\Logger::INFO # Configures the level of messages to capture as breadcrumbs
1620

1721
monolog:
1822
handlers:
19-
# Register the breadcrumb handler as a Monolog handler
23+
# (Optionally) Register the breadcrumb handler as a Monolog handler
2024
sentry_breadcrumbs:
2125
type: service
2226
name: sentry_breadcrumbs
@@ -26,4 +30,6 @@ monolog:
2630
type: sentry
2731
level: !php/const Monolog\Logger::ERROR # Configures the level of messages to capture as events
2832
hub_id: Sentry\State\HubInterface
33+
fill_extra_context: true # Enables sending monolog context to Sentry
34+
process_psr_3_messages: false # Disables the resolution of PSR-3 placeholders in reported messages
2935
```

0 commit comments

Comments
 (0)