diff --git a/README.md b/README.md index e19e443..819f3d6 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,9 @@ Configure the module in `/etc/apache2/mods-enabled/log_gelf.conf`: GelfCookie "tracking" GelfFields "ABDhmsvRti" ``` + +You can use GelfSource "CURRENT_HOSTNAME" in order to use name of the host where apache is running. + On CentOS both files are combined in `/etc/httpd/conf.modules.d/02-gelf.conf` | Parameter | Argument | Description | diff --git a/src/mod_log_gelf.c b/src/mod_log_gelf.c index e54f9d1..e3a0acb 100644 --- a/src/mod_log_gelf.c +++ b/src/mod_log_gelf.c @@ -159,7 +159,14 @@ static const char *set_gelf_tag(cmd_parms *cmd, void *cfg, const char *arg) { /* Override source field */ static const char *set_gelf_source(cmd_parms *cmd, void *cfg, const char *arg) { gelf_config *config = ap_get_module_config(cmd->server->module_config, &log_gelf_module); - config->source = arg; + if (strcmp(arg,"CURRENT_HOSTNAME") == 0) { + char local_hostname[1024]; + local_hostname[1023]='\0'; + gethostname(local_hostname, 1023); + config->source = strdup(local_hostname); + } else { + config->source = arg; + } return NULL; }