stdoutFile
Description:
static string Worker::$stdoutFile
This property is a global static property. If running in daemon mode (-d startup), all output to the terminal (such as echo, var_dump, etc.) will be redirected to the file specified by stdoutFile.
If not set, and running in daemon mode, all terminal output will be redirected to /dev/null (which means all output is discarded by default).
Note:
/dev/nullis a special file in Linux; it is essentially a black hole, and all data written to this file will be discarded. If you do not want to discard the output, you can setWorker::$stdoutFileto a normal file path.Note: This property must be set before
Worker::runAll();is executed to take effect. This feature is not supported on Windows systems.
Example
use Workerman\Worker;
require_once __DIR__ . '/vendor/autoload.php';
Worker::$daemonize = true;
// All print output will be saved in /tmp/stdout.log file
Worker::$stdoutFile = '/tmp/stdout.log';
$worker = new Worker('text://0.0.0.0:8484');
$worker->onWorkerStart = function($worker)
{
echo "Worker start\n";
};
// Run the worker
Worker::runAll();