首页
下载
文档
社区
视频
捐赠
源代码
赞助商
AOT 编译器
AI 助理
商业产品
PHP AOT 原生编译器
Swoole-Compiler 代码加密器
CRMEB 新零售社交电商系统
登录
注册
全部
提问
分享
讨论
建议
公告
开发框架
CodeGalaxy
发表新帖
echo/var_dump/print 无法写入到 log_file
### 问题描述 ### Swoole4.5.8 4.5.7,PHP7.3 7.4,centos7.8 ### 相关代码 ```php /** * 执行服务 */ function run() { $config = $this->config['proxy']; //创建Server对象 $server = new Swoole\Server($config['host'], $config['port']); //配置Server进程 $server->set( array( 'daemonize' => $config['daemonize'], //Worker 进程数 'worker_num' => $config['worker_num'], //task_worker 进程数 'task_worker_num' => $config['task_worker_num'], //退出最大任务数 'max_request' => $config['max_request'], //打开EOF检测 'open_eof_check' => $config['open_eof_check'], //设置EOF 'package_eof' => $config['package_eof'], //log日志 'log_file' => $config['log_file'], //log日志等级 'log_level' => $config['log_level'] ) ); //监听进程启动事件 $server->on('WorkerStart', array($this, 'onWorkerStart')); //监听启动事件 $server->on('Start', array($this, 'onStart')); //监听Task事件 $server->on('Task', array($this, 'onTask')); //监听连接打开事件 $server->on('Connect', array($this, 'onConnect')); //监听消息事件 $server->on('Receive', array($this, 'onReceive')); //监听连接关闭事件 $server->on('Close', array($this, 'onClose')); //启动 $server->start(); } /** * 监听进程启动事件 */ function onWorkerStart($server, $worker_id) { if (!$server->taskworker && $worker_id == 0) { //定时任务 if ($this->config['proxy']['isopen_task']) { echo "启动task服务成功\n"; $this->taskTimer($server); } } } /** * 监听启动事件 */ function onStart($server) { echo "转发服务启动成功 \n"; } /** * 监听连接打开事件 */ function onConnect($server, $fd) { echo "Client: " . $fd . " Connect.\n"; } ``` ### 只有onStart的echo能写入log_file,其它的地方都无法写入。log_level等级全部试过,还有Debug 参数也编译了。
发布于5年前 · 5 次浏览 · 来自
提问
guge
### 问题描述 ### Swoole4.5.8 4.5.7,PHP7.3 7.4,centos7.8 ### 相关代码 ```php /** * 执行服务 */ function run() { $config = $this->config['proxy']; //创建Server对象 $server = new Swoole\Server($config['host'], $config['port']); //配置Server进程 $server->set( array( 'daemonize' => $config['daemonize'], //Worker 进程数 'worker_num' => $config['worker_num'], //task_worker 进程数 'task_worker_num' => $config['task_worker_num'], //退出最大任务数 'max_request' => $config['max_request'], //打开EOF检测 'open_eof_check' => $config['open_eof_check'], //设置EOF 'package_eof' => $config['package_eof'], //log日志 'log_file' => $config['log_file'], //log日志等级 'log_level' => $config['log_level'] ) ); //监听进程启动事件 $server->on('WorkerStart', array($this, 'onWorkerStart')); //监听启动事件 $server->on('Start', array($this, 'onStart')); //监听Task事件 $server->on('Task', array($this, 'onTask')); //监听连接打开事件 $server->on('Connect', array($this, 'onConnect')); //监听消息事件 $server->on('Receive', array($this, 'onReceive')); //监听连接关闭事件 $server->on('Close', array($this, 'onClose')); //启动 $server->start(); } /** * 监听进程启动事件 */ function onWorkerStart($server, $worker_id) { if (!$server->taskworker && $worker_id == 0) { //定时任务 if ($this->config['proxy']['isopen_task']) { echo "启动task服务成功\n"; $this->taskTimer($server); } } } /** * 监听启动事件 */ function onStart($server) { echo "转发服务启动成功 \n"; } /** * 监听连接打开事件 */ function onConnect($server, $fd) { echo "Client: " . $fd . " Connect.\n"; } ``` ### 只有onStart的echo能写入log_file,其它的地方都无法写入。log_level等级全部试过,还有Debug 参数也编译了。
赞
0
收藏
提问
分享
讨论
建议
公告
开发框架
CodeGalaxy
登录
后参与评论
评论
2020-11-25
鲁飞
你的config配置是什么?我这里未复现问题。
赞
0
回复
2020-11-25
guge
回复
鲁飞
$config['proxy'] = array( //是否开启转发服务 'isopen' => 1, //是否开启定时 'isopen_task' => 1, //转发服务内网ip 'ip' => '192.168.1.8', //监听的HOST 'host' => '0.0.0.0', //监听的端口 'port' => '9500', //口令 'secret' => 'MgwwjZAngzjkU2V5m', //Worker 进程数 'worker_num' => 3, //task_worker 进程数 'task_worker_num' => 4, //退出最大任务数 'max_request' => 0, //守护进程 'daemonize' => 1, //log日志 'log_file' => 'proxy.log', //log日志等级 'log_level' => 0, //打开EOF检测 'open_eof_check' => true, //设置EOF 'package_eof' => "\gu\ge", );
赞
0
回复
2020-11-25
鲁飞
回复
guge
log_file 使用绝对路径或者相对路径。不要直接一个文件名
赞
0
回复
2020-11-25
guge
回复
鲁飞
多谢,原来这样
赞
0
回复