Sending Laravel logs to Railway's logger

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('LOG_STDERR_FORMATTER'), '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? ☮️ 🙏
5 Replies
Percy
Percy4mo ago
Project ID: 7605ac5c-d0a3-4cfb-a00a-49878fd419a8
Josh Larson
Josh Larson4mo ago
7605ac5c-d0a3-4cfb-a00a-49878fd419a8
Brody
Brody4mo ago
Does php-fpm swallow these logs? Like, do they go into the ether?
good question, i have no clue
Or 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
Josh Larson
Josh Larson4mo ago
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.