apache模块ap_log_perror与ap_log_error处于不同级别 [英] apache modules ap_log_perror is at a different level than ap_log_error

查看:405
本文介绍了apache模块ap_log_perror与ap_log_error处于不同级别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个记录一些行的apache模块.如果我使用ap_log_error登录并设置了LogLevel进行调试,则会看到此消息.但是,如果尝试使用ap_log_perror,则可以看到错误级别的日志,但调试日志不会显示.看起来好像两者处于不同的级别,但是我不知道如何设置池的级别(或就此而言获取它).

I have an apache module that logs some lines. If I log with ap_log_error and have set LogLevel to debug I see the message. However, if I try to use ap_log_perror I can see error-level logs but the debug logs don't show up. It seems as if the two are at a different level, but I can't figure out how to set the pool's level (or get it for that matter).

我看到有一个呼叫ap_get_server_module_loglevel,但是我不确定正确的索引是什么.尝试0我看到我在apache.conf顶层设置的级别(在这种情况下为trace1).没有配置日志级别的虚拟主机.我有权访问的每个池的行为似乎都相同.

I see there's a call ap_get_server_module_loglevel but I'm not sure what the right index is. Trying 0 I see the level I set in the apache.conf toplevel (trace1 in this case). There are no virtual hosts with log levels configured. Every pool I have access to appears to behave in the same way.

static int foo_setup_handler(apr_pool_t *pconf, 
                             apr_pool_t *plog,
                             apr_pool_t *ptemp, 
                             server_rec *s) {
    int mod_log = ap_get_server_module_loglevel(s, 0);
    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, 
                 "Post Config  server mod 0 loglevel %d", 
                  mod_log);
    ap_log_perror(APLOG_MARK, APLOG_ERR, APR_SUCCESS, pconf,
                  " P E++++++++++++++++");
    ap_log_perror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, pconf, 
                  "P D conf ++++++++++++++++");
    ap_log_perror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, plog, 
                  "P D log ++++++++++++++++");
    ap_log_perror(APLOG_MARK, APLOG_WARNING, APR_SUCCESS, plog, 
                  "P W log ++++++++++++++++");
    ap_log_perror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, ptemp, 
                  "P D temp++++++++++++++++");

,这是错误日志中的输出. (我从下面的行中删除了日期和线程ID)

and here's the output in the error log. (I removed the date and thread id from the line below)

... [:debug] [pid 2..:tid 1...] mod_foo.c(123): Post Config  server mod 0 loglevel 8
... [:error] [pid 2..:tid 1...]  P E++++++++++++++++
... [:warn] [pid 2..:tid 1...] P W log ++++++++++++++++

为什么没有在配置级别上显示错误日志消息,而在警告或错误级别上显示错误日志消息?

any ideas why perror log messages are not showing up at the configured level but do show up at the WARNING or ERROR level?

推荐答案

这是一个错误吗?在Apache中.请参见此错误报告.

This is a bug? in Apache. See this bug report.

基本上,ap_log_perrorconst server_rec *s设置为NULL的情况下调用log_error_core,这与逻辑

Basically, ap_log_perror calls log_error_core with const server_rec *s set to NULL, and that runs afoul of the logic here:

if (s == NULL) {
    /*
     * If we are doing stderr logging (startup), don't log messages that are
     * above the default server log level unless it is a startup/shutdown
     * notice
     */
#ifndef DEBUG
    if ((level_and_mask != APLOG_NOTICE)
        && (level_and_mask > ap_default_loglevel)) {
        return;
    }
#endif

因此ap_log_perror将仅显示通知或高于默认级别的消息(通常为警告)

So ap_log_perror will only ever show Notices, or messages above the default level (which is normally Warning)

这篇关于apache模块ap_log_perror与ap_log_error处于不同级别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆