Apache:仅为某些模块配置“LogLevel debug”?

Apache:仅为某些模块配置“LogLevel debug”?

我想调试我的网络服务器上的一些身份验证和授权问题,特别是 mod_authnz_ldap 和其他 mod_auth* 模块。

因此,我设置了LogLevel debugApache 配置,无论是全局配置还是单个 VirtualHost 配置。这为我提供了来自 mod_authnz_ldap 的有用信息,但同时也从 SSL 模块中发出了大量噪音。请参阅下面的示例。

有没有办法降低 ssl_engine* 的日志级别,同时仍保持 mod_authnz_ldap 的日志级别?

是的,我可以使用类似 的方法排除这些行grep -v ssl_engine logfile,但我还想从其他系统日志解析工具中排除这些额外数据。我宁愿减少源日志,而不是在目标中排除它。

[Tue Jul 06 16:55:31 2010] [debug] ssl_engine_io.c(1830): | 0100: 12 23 e7 0f 45 1f 1f d3-ed 12 f8 12 1f a9 90 85  .+..(........... |
[Tue Jul 06 16:55:31 2010] [debug] mod_authnz_ldap.c(474): [client 10.10.10.123] [96991] auth_ldap authenticate: accepting joe
[Tue Jul 06 16:55:31 2010] [debug] mod_authnz_ldap.c(730): [client 10.10.10.123] [96991] auth_ldap authorise: require group: authorisation successful (attribute memberUid) [Comparison true (cached)][Compare True]
[Tue Jul 06 17:02:17 2010] [debug] ssl_engine_io.c(1830): | 0023: 23 ff 29 5a 4b bd 4c e6-bc 36 22 9c c3 22 c2 4b  ..)ZK.L..6u....K |
[Tue Jul 06 17:02:17 2010] [debug] ssl_engine_io.c(1830): | 0023: 23 ff 29 5a 4b bd 4c e6-bc 22 75 9c c3 b6 22 4b  ..)blahblah|

答案1

我正在以《危险边缘》风格回答我自己的问题。

Apache 2.3

这在 Apache 2.3 中是可能的。

Apache > HTTP 服务器 > 文档 > 版本 2.4 > 每个模块的日志记录说:

每个模块的日志记录

LogLevel 指令允许您根据每个模块指定日志严重性级别。这样,如果您正在排除某个特定模块的问题,则可以调高其日志记录量,而无需获取您不感兴趣的其他模块的详细信息。这对于 mod_proxy 或 mod_rewrite 等模块特别有用,因为您想了解它们正在尝试执行的操作的详细信息。

通过在 LogLevel 指令中指定模块的名称来执行此操作:

LogLevel info rewrite:trace5

这会将主 LogLevel 设置为 info,但对于 mod_rewrite 则将其调高至 trace5。

这将取代服务器早期版本中存在的每个模块日志记录指令,例如 RewriteLog。

Apache HTTP Server 2.4 中的新功能概述说:

每个模块和每个目录的 LogLevel 配置现在可以按模块和每个目录配置 LogLevel。在调试日志级别之上添加了新的级别 trace1 到 trace8。

另请参阅讨论在 Apache-dev 上邮件列表。

Apache 2.2 及更早版本:

不可以,目前在 Apache 2.2 中还无法实现。手册位于 HTTP Server > 文档 > 版本 2.2 > 模块“LogLevel 指令”不显示此选项。目前唯一的选项是“grep -v”有问题的行。

Apache 2.4(撰写本文时提议):

这将包含在 Apache 2.4 中。Apache 文档位于树干(2.3)目前说:

兼容性:Apache HTTP Server 2.3.6 及更高版本中提供按模块和按目录配置

和:

指定不带模块名称的级别会将所有模块的级别重置为该级别。指定带模块名称的级别将仅为该模块设置级别。可以使用模块源文件名、模块标识符或省略尾随 _module 的模块标识符作为模块规范。这意味着以下三个规范是等效的:

LogLevel info ssl:warn
LogLevel info mod_ssl.c:warn
LogLevel info ssl_module:warn

相关内容