Ap_log_error not registering in my apache module

I have this code in the apache module I'm working on, which is registered with ap_hook_child_init ():

static class_name *mc; static void child_init(apr_pool_t *pool, server_rec *s) { ap_log_error(APLOG_MARK, APLOG_INFO, 0, s, "this pointer should be null: %pp", mc); mc = mc_alloc(); ap_log_error(APLOG_MARK, APLOG_INFO, 0, s, "this pointer should not be null: %pp", mc); } 

Problem: I do not see these log messages!

I am sure that this function is called and that the mc_alloc() call works, because when I register from other parts of the modules (for example, in the request handler), I see the log messages and get a valid result for the pointer. It also tells me that logging works.

Is my code wrong or my expectations? Can't issue a log message during ap_hook_child_init callback? If not, how else can I register that the child was init'ed?

+4
source share
1 answer

So it turns out that this is not a code problem, it was a configuration problem.

In /etc/apache2/sites-enabled/my_site.conf I installed LogLevel Info in my <VirtualHost> section, which apparently does not install it for the entire server.

I discovered this by changing the value from APLOG_INFO to APLOG_CRIT . As soon as I did this, messages appeared in the journal. Therefore, I knew that the server was registering correctly, and my code was working.

This led me to believe that there were separate possible LogLevel settings and that I was probably too specific where mine was. Adding the LogLevel Info directive outside the <VirtualHost> section was apparently necessary so that the entire server would log more messages than the default.

+4
source

All Articles