Skip to content

Commit b28e8e8

Browse files
authored
Update README.md
Add clarity about exception logging, as discussed in #16
1 parent 387d8cf commit b28e8e8

File tree

1 file changed

+42
-34
lines changed

1 file changed

+42
-34
lines changed

README.md

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
Laravel Rollbar
2-
===============
1+
# Laravel Rollbar
2+
=================
33

44
[![Build Status](https://travis-ci.org/rollbar/rollbar-php-laravel.svg?branch=master)](https://travis-ci.org/rollbar/rollbar-laravel)
55

66
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'.
77

88
![rollbar](https://d37gvrvc0wt4s1.cloudfront.net/static/img/features-dashboard1.png?ts=1361907905)
99

10-
Installation
11-
------------
10+
## Installation
11+
---------------
1212

1313
Install using composer:
1414

1515
```
1616
composer require rollbar/rollbar-laravel
1717
```
1818

19-
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`:
2020

2121
```
2222
ROLLBAR_TOKEN=[your Rollbar project access token]
2323
```
2424

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):
2626

2727
```php
2828
Rollbar\Laravel\RollbarServiceProvider::class,
2929
```
30-
30+
3131
If you only want to enable Rollbar reporting for certain environments you can conditionally load the service provider in your `AppServiceProvider`:
3232

3333
```php
@@ -39,12 +39,12 @@ public function register()
3939
}
4040
```
4141

42-
Configuration
43-
-------------
42+
## Configuration
43+
----------------
4444

4545
Setting up `ROLLBAR_TOKEN` in .env should be enough for basic configuration.
4646

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:
4848

4949
```php
5050
'rollbar' => [
@@ -53,40 +53,23 @@ This package supports configuration through the services configuration file loca
5353
],
5454
```
5555

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.
7057

58+
## Usage
59+
--------
7160

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.
7362

74-
```php
75-
App::error(function(Exception $exception, $code)
76-
{
77-
Log::error($exception);
78-
});
79-
```
63+
### Logging a Specific Message
8064

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:
8266

8367
```php
8468
\Log::debug('Here is some debug information');
8569
```
8670

87-
*NOTE*: Fatal exceptions will always be sent to Rollbar.
8871

89-
### Context informaton
72+
### Adding Context Informaton
9073

9174
You can pass user information as context like this:
9275

@@ -103,3 +86,28 @@ Or pass some extra information:
10386
'download_size' => 3432425235
10487
]);
10588
```
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`:
107+
108+
```php
109+
App::error(function(Exception $exception, $code)
110+
{
111+
Log::error($exception);
112+
});
113+
```

0 commit comments

Comments
 (0)