PostgreSQL 数据库默认数据库日志收集功能为关闭,但PostgreSQL 官方建议开启该参数,但该参数开启需要配合多个参数才能完成,本节只介绍logging_collector ,如下
一 logging_collector(
boolean
)
logging_collector --是否开启日志收集开关,默认off,推荐on
This parameter enables the logging collector, which is a background process that captures log messages sent to stderr and redirects them into log files. This approach is often more useful than logging to syslog, since some types of messages might not appear in syslog output. (One common example is dynamic-linker failure messages; another is error messages produced by scripts such as archive_command
.) This parameter can only be set at server start.
(此参数启用日志收集器,日志收集器是一个后台进程,它捕获发送到stderr的日志消息并将其重定向到日志文件中。这种方法通常比将日志记录到syslog更有用,因为某些类型的消息可能不会出现在syslog输出中。(一个常见的例子是动态链接器故障消息;另一种是由脚本(如archive_command)产生的错误消息。该参数只能在服务器启动时设置。)
该参数注意事项:
1.It is possible to log to stderr without using the logging collector; the log messages will just go to wherever the server's stderr is directed. However, that method is only suitable for low log volumes, since it provides no convenient way to rotate log files. Also, on some platforms not using the logging collector can result in lost or garbled log output, because multiple processes writing concurrently to the same log file can overwrite each other's output.
(可以在不使用日志收集器的情况下记录到stderr;日志消息将直接发送到服务器的标准错误所指向的任何地方。但是,该方法只适用于低日志卷,因为它不提供旋转日志文件的方便方法。此外,在一些不使用日志收集器的平台上,可能会导致日志输出丢失或乱码,因为并发地写同一日志文件的多个进程可能会覆盖彼此的输出。)
2.The logging collector is designed to never lose messages. This means that in case of extremely high load, server processes could be blocked while trying to send additional log messages when the collector has fallen behind. In contrast, syslog prefers to drop messages if it cannot write them, which means it may fail to log some messages in such cases but it will not block the rest of the system.
(日志收集器被设计为永远不会丢失消息。这意味着,在负载非常高的情况下,当收集器落后时,服务器进程可能会在尝试发送额外的日志消息时被阻塞。相反,如果syslog不能写入消息,则更倾向于丢弃消息,这意味着在这种情况下,它可能无法记录某些消息,但不会阻塞系统的其余部分。)
应用文档:https://www.postgresql.org/docs/16/runtime-config-logging.html
标签:logging,log,收集器,messages,PostgreSQL,日志,collector From: https://www.cnblogs.com/wangguanghui-83767582/p/17964078