gpt4 book ai didi

python - Cloudwatch 代理错误 : No option 'file' in section: 'loggers'

转载 作者:太空宇宙 更新时间:2023-11-03 14:57:33 25 4
gpt4 key购买 nike

我正在尝试调整 Cloudwatch Logs Agent 中各种记录器的日志级别,并根据 official AWS reference docs ,它指出我应该能够将以下内容添加到/var/awslogs/etc/awslogs.conf,以实现这一点:

[loggers]
keys=root,cwlogs,reader,publisher

[handlers]
keys=consoleHandler

[formatters]
keys=simpleFormatter

[logger_root]
level=INFO
handlers=consoleHandler

[logger_cwlogs]
level=INFO
handlers=consoleHandler
qualname=cwlogs.push
propagate=0

[logger_reader]
level=WARNING
handlers=consoleHandler
qualname=cwlogs.push.reader
propagate=0

[logger_publisher]
level=WARNING
handlers=consoleHandler
qualname=cwlogs.push.publisher
propagate=0

[handler_consoleHandler]
class=logging.StreamHandler
level=INFO
formatter=simpleFormatter
args=(sys.stderr,)

[formatter_simpleFormatter]
format=%(asctime)s - %(name)s - %(levelname)s - %(process)d - %(threadName)s - %(message)s

当我添加它时,日志转发停止,我在 /var/log/awslogs.log 中看到相关条目:

在“loggers”部分没有选项“file”

删除整个部分会恢复日志记录,但是 - 显然 - 没有调整日志级别。

知道我可能做错了什么吗?

最佳答案

不要将这些选项添加到 awslogs.conf。将它们添加到一个单独的文件中,然后您通过 awslogs.conf 中的 logging_config_file 键指定该文件:

/etc/awslogs/awslogs.conf

[general]
state_file = /var/lib/awslogs/agent-state
logging_config_file = /etc/awslogs/logging.conf
use_gzip_http_content_encoding = false
...

/etc/awslogs/logging.conf

[loggers]
keys=root,cwlogs,reader,publisher
file=/tmp/test

[handlers]
keys=consoleHandler

[formatters]
keys=simpleFormatter

[logger_root]
level=INFO
handlers=consoleHandler

[logger_cwlogs]
level=INFO
handlers=consoleHandler
qualname=cwlogs.push
propagate=0

[logger_reader]
level=WARNING
handlers=consoleHandler
qualname=cwlogs.push.reader
propagate=0

[logger_publisher]
level=WARNING
handlers=consoleHandler
qualname=cwlogs.push.publisher
propagate=0

[handler_consoleHandler]
class=logging.StreamHandler
level=INFO
formatter=simpleFormatter
args=(sys.stderr,)

[formatter_simpleFormatter]
format=%(asctime)s - %(name)s - %(levelname)s - %(process)d - %(threadName)s - %(message)s

关于python - Cloudwatch 代理错误 : No option 'file' in section: 'loggers' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41259941/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com