php - 在 centos 7 和使用 php 7 系统日志功能选项卡的日志记录为 ascii 十六进制代码 \x09
问题描述
有谁知道为什么当我在 centos 7.5 机器上运行下面的代码时,选项卡会输出为 \x09?我已经进行了很多挖掘,但找不到解决方案。我相信这可能与我的语言环境设置有关,但一切都设置为 en_US.UTF-8。
php -r 'syslog(LOG_NOTICE, "test\t");'
这会产生:
Apr 3 08:06:23 php: test\x09
在我运行 ubuntu 18.04 的笔记本电脑上,该选项卡按我的预期记录,有 8 个空格。
注意我已经使用 syslog 对此进行了测试,syslog-ng 和 rsyslog 都产生了相同的结果。
使用 strace 看起来 php 正在转义选项卡
sendto(3, "<13>Apr 3 09:27:35 php: test\\x0"..., 38, MSG_NOSIGNAL, NULL, 0) = 38
解决方案
我想到了。显然在 php 7 中他们添加了一个 syslog.filter 设置,它默认为 no_ctrl。我将其更改为“全部”并且 php 停止转义选项卡。
; Set this to disable filtering control characters (the default).
; Some loggers only accept NVT-ASCII, others accept anything that's not
; control characters. If your logger accepts everything, then no filtering
; is needed at all.
; Allowed values are:
; ascii (only base ASCII characters)
; no_ctrl (all characters except control characters)
; all (all characters)
syslog.filter = all
推荐阅读
- autodesk-forge - 根据 manifest.json 中提供的奇怪 URI 获取文件返回 404
- java - 从 Webapp 启动远程可执行文件
- html - 将图像添加到自定义复选框
- javascript - 现场下载 json/show 并通过 ajax 和 jquery 删除
- asp.net - 在 Microsoft Edge 中单击图像按钮时出错
- php - 在从 jQuery $.post(...) 调用的 AJAX 页面中获取 $_POST 数组
- python - 训练时在图像批处理数据上添加白噪声
- search - 在 Prestashop 中更改搜索方法
- elasticsearch - Kibana Windows zip 分发解压时间太长
- javascript - getElementsByClassName 的索引未定义,但不是整个对象