2

I can run the following from the PHP 5.4.16 CLI:

ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
$conn = ldap_connect($hostname);
ldap_bind($conn, $ldaprdn);

And I will get a lot of debug output to stderr that starts like this:

ldap_create
ldap_url_parse_ext(ldaps://ldap.example.com)
ldap_bind_s
ldap_simple_bind_s
ldap_sasl_bind_s
ldap_sasl_bind
ldap_send_initial_request
...

That is great for debugging on the CLI. However, I need to debug from within Apache 2.2.15 mod_php because I am seeing intermittent LDAP connectivity there that I cannot reproduce on the command line.

I thought I could run the same code from the web server and see that debug information in Apache's error log, but the messages are not showing up there. PHP errors/warnings are definitely going to the error log, and I tried error_reporting(-1), but can't get those debug messages to show anywhere.

Is there some way I can see those stderr debug messages when running under Apache?

molecularbear
  • 131
  • 1
  • 7
  • Did you try reading `php://stderr` with file_get_contents, for example? – Maerlyn Feb 18 '14 at 15:09
  • 1
    The [PHP stream docs](http://www.php.net/manual/en/wrappers.php.php) specify that `php://stderr` is write-only. I did give it a try; script hangs on the command line, and reads nothing when under Apache. – molecularbear Feb 20 '14 at 14:47
  • For Windows, see also https://stackoverflow.com/q/27480372/2908724. – bishop Feb 20 '18 at 21:24

1 Answers1

2

The answer is that those messages are being logged, but to a different log file than where the error_log() messages go. In my Apache conf, each virtual host has its own error log file. There is also a global error log file where Apache startup/shutdown messages show up.

I was running these LDAP debug scripts on a virtual host and expecting the error output to go to the host's defined error log... just like all other error messages do. But for some reason those ldap debug lines get sent to the global error log.

molecularbear
  • 131
  • 1
  • 7
  • 1
    This is a tough piece of information to find. In my case, the debug information showed up in `error_log` instead of the vhost log or even the ssl server error log. – mvreijn Sep 28 '18 at 14:02