【问题标题】:Unable to get log message in the error.log file APACHE Module?无法在 error.log 文件 APACHE 模块中获取日志消息?
【发布时间】:2013-12-17 13:47:48
【问题描述】:

这是我的代码,用 Visual Studio 2008 编写,代码编译并成功运行我通过调试代码检查,我没有在我的 error.log 消息文件中收到日志消息,如果我犯了一些错误,请帮助我

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "apr_optional.h"
#include <httpd.h>
#include <http_protocol.h>
#include <http_config.h>
#include <http_log.h>
#include "apr_general.h"
#include "apr_getopt.h"
#include "apr_xml.h"
#include "apr_file_io.h"
static int hello_handler(request_rec *r) 
{ 



    ap_log_error(APLOG_MARK,APLOG_INFO,0,NULL,"Entered Function = hello_handler, time = %d",r->finfo.mtime);



        /* We set the content type before doing anything else */ 
 //       ap_set_content_type(r, "text/html"); 

        /* If the request is for a header only, and not a request for 
         * the whole content, then return OK now. We don't have to do 
         * anything else. */ 
        if (r->header_only) 
        { 
                return OK; 
        } 

     ap_log_error(APLOG_MARK,APLOG_INFO,0,NULL, "Exit Function = hello_handler,time = %d",r->finfo.mtime);
} 


static void InitLog_Hooks(apr_pool_t *pool)
{
    ap_hook_handler(hello_handler, NULL, NULL, APR_HOOK_LAST);
}

module AP_MODULE_DECLARE_DATA SampleLog_modules = {
    STANDARD20_MODULE_STUFF,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    InitLog_Hooks
} ;

【问题讨论】:

  • 我尝试在“httpd.conf”配置文件中将日志级别更改为信息,但没有帮助

标签: c windows apache logging apache-modules


【解决方案1】:

这很容易..只需将第四个参数更改为 r->服务器 您将在 error.log 文件中收到错误消息。 我们也可以使用 api 将日志消息重定向到我们自己的文件

ap_replace_stderr_log (pool,"Filepath");

干杯!!

【讨论】:

    猜你喜欢
    • 2019-05-27
    • 1970-01-01
    • 2020-10-23
    • 1970-01-01
    • 2013-09-11
    • 2015-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多