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
Rollbar error monitoring integration for Laravel projects. This library adds a listener to Laravel's logging component. Laravel's session information will be sent in to Rollbar, as well as some other helpful information such as 'environment', 'server', and 'session'.
Add Project Access Token `post_server_item` from Rollbar.com -> Settings -> Project Access Tokens to .env:
19
+
Add Project Access Token `post_server_item` from Rollbar.com -> Settings -> Project Access Tokens to `.env`:
20
20
21
21
```
22
22
ROLLBAR_TOKEN=[your Rollbar project access token]
23
23
```
24
24
25
-
Add the service provider to the `'providers'` array in `config/app.php`:
25
+
Add the service provider to the `'providers'` array in `config/app.php` (this package also supports Laravel 5.5's auto-discovery, which allows you to skip this step):
26
26
27
27
```php
28
28
Rollbar\Laravel\RollbarServiceProvider::class,
29
29
```
30
-
30
+
31
31
If you only want to enable Rollbar reporting for certain environments you can conditionally load the service provider in your `AppServiceProvider`:
32
32
33
33
```php
@@ -39,12 +39,12 @@ public function register()
39
39
}
40
40
```
41
41
42
-
Configuration
43
-
-------------
42
+
## Configuration
43
+
----------------
44
44
45
45
Setting up `ROLLBAR_TOKEN` in .env should be enough for basic configuration.
46
46
47
-
This package supports configuration through the services configuration file located in `config/services.php`. All configuration variables will be directly passed to Rollbar:
47
+
This package supports configuration through the services configuration file located in `config/services.php`. All rollbar configuration variables will be directly passed to Rollbar:
48
48
49
49
```php
50
50
'rollbar' => [
@@ -53,40 +53,23 @@ This package supports configuration through the services configuration file loca
53
53
],
54
54
```
55
55
56
-
The level variable defines the minimum log level at which log messages are sent to Rollbar. For development you could set this either to `debug` to send all log messages, or to `none` to sent no messages at all. For production you could set this to `error` so that all info and debug messages are ignored.
57
-
58
-
Usage
59
-
-----
60
-
61
-
To automatically monitor exceptions, simply use the `Log` facade in your error handler in `app/Exceptions/Handler.php`:
62
-
63
-
```php
64
-
public function report(Exception $exception)
65
-
{
66
-
\Log::error($exception);
67
-
return parent::report($exception);
68
-
}
69
-
```
56
+
The level variable defines the minimum log level at which log messages are sent to Rollbar. If not specified, the default is `debug`. For development you could set this either to `debug` to send `all` log messages, or to `none` to send no messages at all. For production you could set this to `error` so that all `info` and `debug` messages are ignored.
70
57
58
+
## Usage
59
+
--------
71
60
72
-
For Laravel 4 installations, this is located in `app/start/global.php`:
61
+
This package will automatically send to Rollbar every logged message whose level is higher than the ROLLBAR_LEVEL you have configured.
73
62
74
-
```php
75
-
App::error(function(Exception $exception, $code)
76
-
{
77
-
Log::error($exception);
78
-
});
79
-
```
63
+
### Logging a Specific Message
80
64
81
-
Your other log messages will also be sent to Rollbar:
65
+
You can log your own messages anywhere in your app. For example, to log a `debug` message:
82
66
83
67
```php
84
68
\Log::debug('Here is some debug information');
85
69
```
86
70
87
-
*NOTE*: Fatal exceptions will always be sent to Rollbar.
88
71
89
-
### Context informaton
72
+
### Adding Context Informaton
90
73
91
74
You can pass user information as context like this:
92
75
@@ -103,3 +86,28 @@ Or pass some extra information:
103
86
'download_size' => 3432425235
104
87
]);
105
88
```
89
+
90
+
### Exception Logging
91
+
---------------------
92
+
*NOTE*: Fatal exceptions will always be sent to Rollbar.
93
+
94
+
Any exceptions that are not listed as `$dontReport` in your `app/Exceptions/Handler.php` or its parent will be sent to Rollbar automatically.
95
+
96
+
If you wish to override this to do more Rollbar reporting, you may do so using the `Log` facade in your error handler in `app/Exceptions/Handler.php`. For example, to log *every* exception add the following:
97
+
98
+
```php
99
+
public function report(Exception $exception)
100
+
{
101
+
\Log::error($exception);
102
+
return parent::report($exception);
103
+
}
104
+
```
105
+
106
+
For Laravel 4 installations, this is located in `app/start/global.php`:
0 commit comments