3.4. 定义日志轮转策略


目录服务器定期轮转当前日志文件并创建一个新文件。但是,您可以使用命令行或 Web 控制台设置轮转策略来更改默认行为。

您可以管理以下轮转设置:

最大日志数
设置要保留的日志文件的最大数量。达到文件数量时,Directory 服务器会在创建新日志文件前删除最旧的日志文件。默认情况下,访问日志为 10,其他日志为 1
最大日志大小(以 MB 为单位)
在轮转日志文件前以 MB 为单位设置日志文件的最大大小。默认情况下,所有日志都是 100 MB。
每次创建新日志
设置日志文件的最长期限。默认情况下,Directory 服务器每周轮转所有日志。
一天的时间
设置轮转日志文件的时间。所有日志都不默认启用此设置。
访问模式
访问模式在新创建的日志文件上设置文件权限。默认情况下,所有日志都是 600

3.4.1. 使用命令行配置日志轮转策略

您可以使用 dsconf config replace 命令修改管理轮转策略的 cn=config DN 条目中的以下属性:

Expand
 访问日志错误日志审计日志审计失败日志安全日志

最大日志数

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

流程

  1. 要将错误日志配置为使用访问模式 600,以保持最大 2 个日志,并使用 100 MB 或每 5 天轮转日志文件,请输入:

    # dsconf -D "cn=Directory Manager" instance_name config replace nsslapd-errorlog-mode=600 nsslapd-errorlog-maxlogsperdir=2 nsslapd-errorlog-maxlogsize=100 nsslapd-errorlog-logrotationtime=5 nsslapd-errorlog-logrotationtimeunit=day
    Copy to Clipboard Toggle word wrap

    有关轮转策略属性的详情,请参阅 Core server configuration attributes description 中的对应部分。

3.4.2. 使用 Web 控制台配置日志轮转策略

要定期归档当前日志文件并创建一个新日志文件,请使用 Web 控制台设置日志文件轮转策略。

先决条件

  • 已登陆到 web 控制台。

流程

  1. 选择 实例。
  2. 导航到 Server Logging 并选择日志类型,如 Error Log

    此时会打开 Error Log Settings 页面。

  3. Rotation Policy 选项卡。
  4. 配置轮转策略参数。例如,设置最大 3 个日志文件、日志大小最大值 110 MB,以及每 3 天创建新日志文件。

    700

  5. Save Rotation Setting 按钮应用更改。
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat