a year ago
Hey pals, trying to sort out how to actually get Laravel to send logs to Railway's console. I'm using the vanilla Nixpacks PHP/Laravel builder: https://github.com/railwayapp/nixpacks/blob/main/src/providers/php/mod.rs
And I've set my logger.php config to use a stdout driver, which is a copy/paste of the stderr driver except with stdout swapped in:
[
'stdout' => [
'driver' => 'monolog',
'handler' => StreamHandler::class,
'formatter' => env('LOGSTDERRFORMATTER'),
'with' => [
'stream' => 'php://stdout',
],
'ignore_exceptions' => false,
],
]
I'm not seeing anything come through - only nginx logs. Any thoughts on how I could route these to the right place? Off-the-cuff thoughts:
Does php-fpm swallow these logs? Like, do they go into the ether?
Or is it possible to write to /dev/stdout from multiple processes like I'm trying to do?
ā®ļø š
1 Replies
a year ago
Does php-fpm swallow these logs? Like, do they go into the ether?
good question, i have no clueOr is it possible to write to /dev/stdout from multiple processes like I'm trying to do?
it should be, thats what nginx does as far as i know
hmmm yeah i'm gonna try on my local machine to see how writing to stdout behaves š¤
hmm chatgpt confirms my suspicions about stdout:
Correct, you cannot directly read from /dev/stdout of another process as if it were a regular file or a pipe that you can open and read from. /dev/stdout is a symbolic link to /proc/self/fd/1, which represents the standard output file descriptor of the current process. Thus, when a process writes to /dev/stdout, it's writing to its own standard output stream, and this stream is not directly accessible to other processes for reading in the way that a file or named pipe might be.
a year ago
seems to work just fine for nginx
@Josh Larson you got this working in the end? We run into the same issue where no Laravel logs appear.
@Pepijn I ended up sending my logs to a 3p store manually :/ I was just thinking though that you could theoretically wire up a multi-process manager and run php artisan pail
to tail the logs to stdout along with the normal output. I haven't tried it yet though
Thanks for your reply. I eventually fixed got it to work by doing some config changes to the php-fpm conf I add in the docker image.
a month ago
Helo. I am having the same troubles with Symfony and monolog. I tried literally every confog valuie possible. No app logs are shown in Railway logs. I ended up writing directly to a file, but this is not a solution, I have multiple projecte migrating and really struggling without logs.
Can someone explain the fix?