0

I'm redirecting all docker logs to google stackdriver, but when I redirect something to /dev/null I spect to not see it in the stackdriver.

This is my current /etc/docker/daemon.json content:

{"live-restore": true,"storage-driver": "overlay2","log-driver":"gcplogs"}

This is my supervisor program to start horizon:

[program:horizon]
command = php /var/www/artisan horizon
stdout_logfile = /dev/null
stdout_logfile_maxbytes = 0
stderr_logfile = /dev/stderr
stderr_logfile_maxbytes = 0
user = root
autostart = true
autorestart = true
priority = 3000

And this is how I call the scheduler:

* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1

But they still sended to stackdriver

stackdriver

How to disable this schedulers logs? (only them, not the rest of usefull logs)

[EDIT]

The log level will not change the output of the jobs being processed. There is an request asking for that https://github.com/laravel/ideas/issues/1516

Bruno Tomé
  • 528
  • 1
  • 6
  • 22
  • 1
    `>> /dev/null 2>&1` redirects output. It doesn't have any impact on logging. You can adjust Laravel's log level in `config/logging.php`. – ceejayoz Sep 10 '19 at 14:03
  • My `config/logging.php` is pointing to stackdriver driver, but this doesn't help with the question **How to disable Laravel scheduler logs** – Bruno Tomé Sep 10 '19 at 14:08
  • The scheduler uses the same logging infrastructure the rest of Laravel does. You can set `'level' => 'warning',` in your logging driver config to reduce the overall noise; it sounds like you don't need this level of debug/info messaging in your stackdriver. – ceejayoz Sep 10 '19 at 14:11
  • (Incidentally, the code that logs these appears to be here: https://github.com/laravel/framework/blob/e04a7ffba8b80b934506783a7d0a161dd52eb2ef/src/Illuminate/Queue/Console/WorkCommand.php#L160) – ceejayoz Sep 10 '19 at 14:14
  • You're right about my `'level'` in stackdriver was pointing to a lower level than `warning'. But even after that they still showing, looking to the this code that you linked, appears that they are logged ignoring the level option. – Bruno Tomé Sep 10 '19 at 14:20
  • https://stackoverflow.com/questions/34652933/how-to-disable-laravel-5-log-file Maybe this answer will help you – Rob Mkrtchyan Sep 10 '19 at 14:41

2 Answers2

1

You are referring to different applications doing different logging.

  1. The docker log configuration which you have sending to gcplogs
  2. The supervisor log configuration which you have sending to /dev/null
  3. The application scheduler which you have sending to /dev/null

But what you are missing is number four;

  1. The laravel application...

The best option for this is to override the environment setting for LOG_CHANNEL when you are running your command line scheduler in a separate .env file.

You can create a copy of your .env say, .env.scheduler and update the LOG_CHANNEL to none and configure a none in your config/logging.php file to something like this (untested):

    'none' => [
        'driver' => 'none',
        'via' =>     \Monolog\Handler\NullHandler:class,
    ],

And then update your scheduler to run:

* * * * * cd /path-to-your-project && php artisan schedule:run --env=scheduler >> /dev/null 2>&1

hope that helps.

Darryl E. Clarke
  • 7,537
  • 3
  • 26
  • 34
  • This --env=schedules seems to be the way, but what about the cached configs? When we run `php artisan config:cache` it will always read from the bootstrap/cache/config.php. Also, I think that part of framework (https://github.com/laravel/framework/blob/e04a7ffba8b80b934506783a7d0a161dd52eb2ef/src/Illuminate/Queue/Console/WorkCommand.php#L180) will always write in the console, no matters the log driver. Is that right? – Bruno Tomé Sep 10 '19 at 21:51
  • 1
    The worker's console output is stdout/stderr, it is separate from logging and you have suppressed it's output with your /dev/null redirects in the cron job. Config Caching is a caveat which I suppose would need a different workaround. – Darryl E. Clarke Sep 11 '19 at 00:05
1

The logs of the provided print screen are made by the Laravel horizon and not by the scheduler and supervisor as I was thinking. To suppress the horizon logs it need to be started with --quiet flag.

Bruno Tomé
  • 528
  • 1
  • 6
  • 22