Apache HTTP Server - 如何在模块上打印到控制台?

时间:2017-11-26 01:44:41

标签: c++ apache ubuntu apache2

我有一个名为mod_mymodule.so的Apache HTTP Server模块,遵循文档here

我真的很想看到我自己的std::cout,所以我可以在运行时看到我的模块被加载以及内部发生了什么,例如:

static int myserver_handler(request_rec *r)
{
    std::cout << "WHY CAN'T I SEE THIS ON THE TERMINAL????" << std::endl; // <----????
    return OK;
}

static void register_hooks(apr_pool_t *pool)
{
    ap_hook_handler(myserver_handler, NULL, NULL, APR_HOOK_LAST);
}

module AP_MODULE_DECLARE_DATA   tofserver_module =
{
    STANDARD20_MODULE_STUFF,
    NULL,            // Per-directory configuration handler
    NULL,            // Merge handler for per-directory configurations
    NULL,            // Per-server configuration handler
    NULL,            // Merge handler for per-server configurations
    NULL,            // Any directives we may have for httpd
    register_hooks   // Our hook registering function
};

1 个答案:

答案 0 :(得分:1)

在调试模式下运行Apache将输出到终端:

sudo apache2ctl -X