Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error logs not appearing in non-local environments (when log-level is "warn") #986

Open
carestad opened this issue Jan 22, 2025 · 2 comments

Comments

@carestad
Copy link

carestad commented Jan 22, 2025

Octane Version

2.6.0

Laravel Version

11.39.0

PHP Version

8.4.3

What server type are you using?

Roadrunner

Server Version

2024.3.2

Database Driver & Version

sqlite

Description

Upon investigating this I have found that:

  • warn as log level seems to not work, warning however works. warn is the default when Laravel's environment is non-local. According to RoadRunner's example .rr.yaml file, warn is listed as one of the accepted values for logs.level.
  • error does not work at all and will not log any errors (for some reason)
  • debug, info and warning seems to log messages of all log levels. So setting --log-level=warning will still yield messages logged with Log::debug()

I have always found it strange that error is rarely outputted to the main process window when running Octane, so I started diving into this. It is especially important to have in debugging stages when hosting via Kubernetes and using either kubectl logs or some external logging service that pulls the kubernetes logs.

After some testing I found that I could get the logs shown by forcing --log-level=info, and later on I also figured out that warning would work.

The downside is that it also logs every single incoming request to the application as well. There does not seem to be any way to disable that part of the logging.

To sum up:

  • log-level=debug, log-level=info, log-level=warning: works, logs all log levels, even though some of them should not log lower log level messages
  • log-level=warn (default): does not log anything
  • log-level=error: does not log logs for any log levels

Reproduction repo: https://github.com/carestad/laravel-octane-logging-stderr

Steps To Reproduce

In routes/web.php:

Route::get('/log', function() {
    logger()->debug('debug log');
    logger()->info('info log');
    logger()->warning('warning log');
    logger()->error('error log');
});

Create a new Laravel application:
laravel new octante-test

Install Octane:
php artisan octane:install --server=roadrunner

Run Octane with defaults:
php artisan --env=production octane:start --server=roadrunner

Then test by sending a request to /log. Nothing should be logged.

Then try re-running Octane with log level warning instead:
php artisan --env=production octane:start --server=roadrunner --log-level=warning

And re-send request to /log. Should log entry now.

Note: we need to force env to be production, otherwise Octane falls back to log-level=debug according to https://github.com/laravel/octane/blob/2.x/src/Commands/StartRoadRunnerCommand.php#L94

@carestad
Copy link
Author

I also just noticed that when running Octane with --log-level=warning, this line should probably not be true but it still seems to be so. Dumping the raw data just before yields that it's level is info even though I have tried forcing it to warning 🤔

{"level":"info","ts":1737563781500783560,"logger":"http","msg":"http log","status":200,"method":"POST","URI":"/log","URL":"/log","remote_address":"127.0.0.1:55690","read_bytes":0,"write_bytes":2,"start":1737563781428513304,"elapsed":72}"

@Cluster2a
Copy link

#984

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants