0

これは私のコードです。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
} ;
4

1 に答える 1

0

これは非常に簡単でした。4 番目のパラメーターを r->server に変更するだけで、error.log ファイルにエラー メッセージが表示されます。また、API を使用して、ログ メッセージを独自のファイルにリダイレクトすることもできます。

ap_replace_stderr_log (pool,"Filepath");

乾杯!!

于 2013-12-19T10:22:36.930 に答える