要在CentOS上定制Filebeat的日志路径,请按照以下步骤操作:
Filebeat的配置文件通常位于/etc/filebeat/filebeat.yml
。使用文本编辑器打开它,例如使用vi编辑器:
sudo vi /etc/filebeat/filebeat.yml
在filebeat.yml
文件中,找到logging.level
和logging.to_files
设置。如果尚未启用文件日志记录,请将logging.to_files
设置为true
。然后,使用logging.files.path
设置自定义日志文件的路径。例如,要将日志文件存储在/custom/log/path
目录中,请进行以下更改:
logging.level: info
logging.to_files: true
logging.files.path: /custom/log/path
在vi编辑器中,按Esc
键,然后输入:wq
并按Enter
键以保存并退出。
要使更改生效,请重启Filebeat服务:
sudo systemctl restart filebeat
现在,Filebeat应该会在您指定的自定义路径/custom/log/path
中记录日志。请确保此目录存在并具有适当的权限,以便Filebeat可以写入日志文件。