3.4. 定义日志轮转策略
目录服务器定期轮转当前日志文件并创建新日志文件。但是,您可以使用命令行或 Web 控制台配置轮转策略。您可以管理以下轮转设置:
- 最大日志数
-
设置要保留的日志文件的最大数量。达到文件数量时,Directory 服务器会在创建新日志文件前删除最旧的日志文件。默认情况下,访问日志为
10
,其他日志为1
。 - 最大日志大小(以 MB 为单位)
-
在轮转日志文件前以 MB 为单位设置日志文件的最大大小。默认情况下,所有日志都为
100
MB 字节。 - 每次创建新日志
- 设置日志文件的最长期限。默认情况下,Directory 服务器每周轮转所有日志。
- 一天的时间
- 设置轮转日志文件的时间。所有日志都不默认启用此设置。
- 访问模式
-
访问模式在新创建的日志文件上设置文件权限。默认情况下,所有日志都是
600
。
3.4.1. 使用命令行配置日志轮转策略
您可以使用 dsconf config replace
命令修改管理轮转策略的以下属性:
访问日志 | 错误日志 | 审计日志 | 审计失败日志 | 安全日志 | |
---|---|---|---|---|---|
最大日志数 | nsslapd-accesslog-maxlogsperdir | nsslapd-errorlog-maxlogsperdir | nsslapd-auditlog-maxlogsperdir | nsslapd-auditfaillog-maxlogsperdir | nsslapd-securitylog-maxlogsperdir |
最大日志大小(以 MB 为单位) | nsslapd-accesslog-maxlogsize | nsslapd-errorlog-maxlogsize | nsslapd-auditlog-maxlogsize | nsslapd-auditfaillog-maxlogsize | nsslapd-securitylog-maxlogsize |
每次创建新日志 | nsslapd-accesslog-logrotationtime, nsslapd-accesslog-logrotationtimeunit | nsslapd-errorlog-logrotationtime, nsslapd-errorlog-logrotationtimeunit | nsslapd-auditlog-logrotationtime, nsslapd-auditlog-logrotationtimeunit | nsslapd-auditfaillog-logrotationtime, nsslapd-auditfaillog-logrotationtimeunit | nsslapd-securitylog-logrotationtime, nsslapd-securitylog-logrotationtimeunit |
一天的时间 | nsslapd-accesslog-logrotationsynchour, nsslapd-accesslog-logrotationsyncmin | nsslapd-errorlog-logrotationsynchour, nsslapd-errorlog-logrotationsyncmin | nsslapd-auditlog-logrotationsynchour, nsslapd-auditlog-logrotationsyncmin | nsslapd-auditfaillog-logrotationsynchour, nsslapd-auditfaillog-logrotationsyncmin | nsslapd-securitylog-logrotationsynchour, nsslapd-securitylog-logrotationsyncmin |
访问模式 | nsslapd-accesslog-mode | nsslapd-errorlog-mode | nsslapd-auditlog-mode | nsslapd-auditfaillog-mode | nsslapd-securitylog-mode |
流程
例如,要将错误日志配置为使用访问模式 600,以保持最大 2 日志,并轮转具有 100 MB 大小或每 5 天的日志文件,请输入:
# dsconf -D "cn=Directory Manager" ldap://server.example.com config replace nsslapd-errorlog-mode=600 nsslapd-errorlog-maxlogsperdir=2 nsslapd-errorlog-maxlogsize=100 nsslapd-errorlog-logrotationtime=5 nsslapd-errorlog-logrotationtimeunit=day
其他资源
- 有关轮转策略属性的详情,请参阅 Configuration and schema 参考指南中的相应部分。
3.4.2. 使用 Web 控制台配置日志轮转策略
您可以使用 Web 控制台管理日志轮转策略。
先决条件
- 已登陆到 web 控制台。
流程
- 选择 实例。
导航到 Server → Logging 并选择日志类型,如
Error Log
。此时会打开 Error Log Settings 页面。
- 点 Rotation Policy 选项卡。
配置轮转策略参数。例如,设置最大 3 个日志文件、日志大小最大值 110 MB,以及每 3 天创建新日志文件。
- 点 Save Rotation Setting 按钮应用更改。
其他资源