You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/platforms/php/guides/symfony/index.mdx
+2-21Lines changed: 2 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,11 +17,12 @@ Install the `sentry/sentry-symfony` bundle:
17
17
composer require sentry/sentry-symfony
18
18
```
19
19
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
+
20
22
## Configure
21
23
22
24
Add your DSN to your `.env` file:
23
25
24
-
25
26
```plain {filename:.env}
26
27
###> sentry/sentry-symfony ###
27
28
SENTRY_DSN="___PUBLIC_DSN___"
@@ -32,26 +33,6 @@ SENTRY_DSN="___PUBLIC_DSN___"
32
33
In order to receive stack trace arguments in your errors, make sure to set `zend.exception_ignore_args: Off` in your php.ini
33
34
</Alert>
34
35
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
-
55
36
## Verify
56
37
57
38
To test that both logger error and exception are correctly sent to sentry.io, you can create the following controller:
Copy file name to clipboardExpand all lines: docs/platforms/php/guides/symfony/integrations/monolog.mdx
+9-3Lines changed: 9 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,17 +6,21 @@ description: "Learn how to enable Sentry's Symfony SDK to capture Monolog events
6
6
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.
7
7
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.
8
8
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
+
10
14
services:
11
-
# Configure the breadcrumb handler as a service
15
+
#(Optionally) Configure the breadcrumb handler as a service (needed for the breadcrumb Monolog handler)
12
16
Sentry\Monolog\BreadcrumbHandler:
13
17
arguments:
14
18
- '@Sentry\State\HubInterface'
15
19
- !php/constMonolog\Logger::INFO # Configures the level of messages to capture as breadcrumbs
16
20
17
21
monolog:
18
22
handlers:
19
-
# Register the breadcrumb handler as a Monolog handler
23
+
#(Optionally) Register the breadcrumb handler as a Monolog handler
20
24
sentry_breadcrumbs:
21
25
type: service
22
26
name: sentry_breadcrumbs
@@ -26,4 +30,6 @@ monolog:
26
30
type: sentry
27
31
level: !php/const Monolog\Logger::ERROR # Configures the level of messages to capture as events
28
32
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
0 commit comments