Changes with Apache 2.0.36
+ *) Introduced -E startup_logfile_name option to httpd to allow admins
+ to begin logging errors immediately. This provides Win32 users
+ an alternative to sending startup errors to the event viewer, and
+ allows other daemon tool authors an alternative to logging to stderr.
+ [William Rowe]
+
*) Fix subreqs with non-defined Content-Types being served improperly.
[Justin Erenkrantz]
*/
AP_DECLARE(void) ap_open_stderr_log(apr_pool_t *p);
+/**
+ * Replace logging to stderr with logging to the given file.
+ * @param p The pool to allocate out of
+ * @param file Name of the file to log stderr output
+ */
+AP_DECLARE(apr_status_t) ap_replace_stderr_log(apr_pool_t *p,
+ const char *file);
+
/**
* Open the error log and replace stderr with it.
* @param s_main The main server
* in apr_getopt() format. Use this for default'ing args that the MPM
* can safely ignore and pass on from its rewrite_args() handler.
*/
-#define AP_SERVER_BASEARGS "C:c:D:d:e:f:vVlLth?X"
+#define AP_SERVER_BASEARGS "C:c:D:d:E:e:f:vVlLth?X"
#ifdef __cplusplus
extern "C" {
apr_file_open_stderr(&stderr_log, p);
}
+AP_DECLARE(apr_status_t) ap_replace_stderr_log(apr_pool_t *p,
+ const char *fname)
+{
+ apr_file_t *stderr_file;
+ apr_status_t rc;
+ char *filename = ap_server_root_relative(p, fname);
+ if (!filename) {
+ ap_log_error(APLOG_MARK, APLOG_STARTUP|APLOG_CRIT,
+ APR_EBADPATH, NULL, "Invalid -E error log file %s",
+ fname);
+ exit(1);
+ }
+ if ((rc = apr_file_open(&stderr_file, filename,
+ APR_APPEND | APR_READ | APR_WRITE | APR_CREATE,
+ APR_OS_DEFAULT, p)) != APR_SUCCESS) {
+ ap_log_error(APLOG_MARK, APLOG_STARTUP, rc, NULL,
+ "%s: could not open error log file %s.",
+ ap_server_argv0, fname);
+ return rc;
+ }
+ if ((rc = apr_file_open_stderr(&stderr_log, p)) == APR_SUCCESS) {
+ apr_file_flush(stderr_log);
+ if ((rc = apr_file_dup2(stderr_log, stderr_file, p)) == APR_SUCCESS) {
+ apr_file_close(stderr_file);
+ }
+ }
+ if (rc != APR_SUCCESS) {
+ ap_log_error(APLOG_MARK, APLOG_CRIT, rc, NULL,
+ "unable to replace stderr with error_log");
+ return rc;
+ }
+}
+
static int log_child(apr_pool_t *p, const char *progname,
apr_file_t **fpin)
{
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
" -e level : show startup errors of level "
"(see LogLevel)");
+ ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
+ " -E file : log startup errors to file");
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
" -v : show version number");
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
int configtestonly = 0;
const char *confname = SERVER_CONFIG_FILE;
const char *def_server_root = HTTPD_ROOT;
+ const char *temp_error_log = NULL;
process_rec *process;
server_rec *server_conf;
apr_pool_t *pglobal;
}
break;
+ case 'E':
+ temp_error_log = apr_pstrdup(process->pool, optarg);
+ break;
+
case 'X':
new = (char **)apr_array_push(ap_server_config_defines);
*new = "DEBUG";
*/
ap_server_root = def_server_root;
+ if (temp_error_log) {
+ ap_replace_stderr_log(process->pool, temp_error_log);
+ }
server_conf = ap_read_config(process, ptemp, confname, &ap_conftree);
if (ap_run_pre_config(pconf, plog, ptemp) != OK) {
ap_log_error(APLOG_MARK, APLOG_STARTUP |APLOG_ERR| APLOG_NOERRNO, 0,
char *pid;
apr_getopt_t *opt;
int running_as_service = 1;
+ int errout = 0;
osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osver);
case 'k':
signal_arg = optarg;
break;
+ case 'E':
+ errout = 1;
+ /* Fall through so the Apache main() handles the 'E' arg */
default:
*(const char **)apr_array_push(mpm_new_argv) =
apr_pstrdup(process->pool, optbuf);
* We hold the return value so that we can die in pre_config
* after logging begins, and the failure can land in the log.
*/
- if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT) {
+ if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT)
+ {
+ if (!errout) {
+ mpm_nt_eventlog_stderr_open(service_name, process->pool);
+ }
service_to_start_success = mpm_service_to_start(&service_name,
process->pool);
if (service_to_start_success == APR_SUCCESS) {
if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT)
{
- mpm_nt_eventlog_stderr_open(mpm_display_name, p);
-
globdat.service_init = CreateEvent(NULL, FALSE, FALSE, NULL);
globdat.service_term = CreateMutex(NULL, TRUE, NULL);
if (!globdat.service_init || !globdat.service_term) {