0

How could i link Laravel log files to PaperTrial ?

According to this article :

http://mattstauffer.co/blog/laravel-forge-logging-with-papertrail#step-4-add-a-syslog-handler

I followed steps and reached to step 4 putting Syslog Monolog handler in the /app/route.php file ,went to PaperTrial dashboard but i didn't see any output.

Any help ? thanks.

animuson
  • 53,861
  • 28
  • 137
  • 147
Yunis Hawwash
  • 98
  • 2
  • 13

3 Answers3

4

For Laravel 5.1 after setting up the forge, you should add to bootstrap/app.php file the following code just before the return of the $app variable

    $app->configureMonologUsing(function($monolog){
        $monolog->pushHandler(new Monolog\Handler\SyslogHandler('papertrail'));
    });

return $app;

The parameter (in this case 'papertrail') can be whatever you want to, this name will show on the papertail's event screen.

  • This seems to stop Laravel logging to the normal 'laravel.log' file. Is there a way to have it logging to both paper trail and the existing local log file? – AndyDunn Jul 27 '16 at 13:34
1

I have it working using the standard logging facility instead of Monolog. This way there is nothing extra to install. Just add this to rsyslogd's conf:

### Laravel Log
$InputFileName /path/to/vhost/dir/app/storage/logs/laravel.log
$InputFileTag laravel-errors-domain.com:
$InputFileStateFile state-laravel-errors-domain.com
$InputFileSeverity error
$InputRunFileMonitor

And make sure that this log gets included in the send action, if you are not sending everything.

Then issue

service rsyslog restart
Gaia
  • 2,872
  • 1
  • 41
  • 59
0

From my experience using Laravel 5.2.* with Forge, Step 4 from that article is not necessary anymore. All you have to do after Step 3 is set your Environment .env settings in Forge to APP_LOG=syslog for each site you want to use with papertrail.

However, this means that Laravel will not log to laravel.log anymore in this environment. But, in other environments (e.g. dev environment) you could of course continue logging to laravel.log by simply not making any changes to the .env file there.

dovid
  • 16
  • 2
  • 3
  • Update: Newer versions of Laravel use LOG_CHANNEL instead of APP_LOG. Ref: https://laravel.com/docs/8.x/logging#configuration – M Wuori Feb 10 '22 at 02:47