要在CentOS上自定义Filebeat的日志路径,您需要编辑Filebeat配置文件
打开终端。
使用文本编辑器打开Filebeat配置文件。例如,您可以使用nano编辑器:
sudo nano /etc/filebeat/filebeat.yml
在配置文件中找到logging.level
和logging.to_files
设置。如果没有找到这些设置,请在filebeat.inputs
部分下添加它们。
将logging.level
设置为所需的日志级别,例如info
、debug
或error
。
logging.level: info
logging.to_files
设置为true
以启用文件日志记录。logging.to_files: true
logging.files
部分下,设置path
和rotateeverybytes
或rotateeveryfiles
选项以自定义日志文件的路径和轮换策略。例如,要将日志文件存储在/custom/log/path/filebeat.log
并每天轮换一次,请添加以下设置:logging.files:
path: /custom/log/path/filebeat.log
rotateeverybytes: 10485760 # 10MB
# 或者
rotateeveryfiles: 1
保存并关闭配置文件。
重新启动Filebeat服务以应用更改:
sudo systemctl restart filebeat
现在,Filebeat应该会在您指定的自定义路径下记录日志,并根据您设置的轮换策略进行轮换。