# Apache custom log through logger not working

**URL:** <https://forums.rockylinux.org/t/apache-custom-log-through-logger-not-working/6226>\
**Category:** Rocky Linux Help & Support\
**Created:** [June 1, 2022, 10:20am UTC](https://forums.rockylinux.org/t/apache-custom-log-through-logger-not-working/6226 "2022-06-01T10:20:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![linuxlover](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/linuxlover/32/2227_2.png) [@linuxlover](https://forums.rockylinux.org/u/linuxlover)\
**Post date:** [June 1, 2022, 10:20am UTC](https://forums.rockylinux.org/t/apache-custom-log-through-logger-not-working/6226/1 "2022-06-01T10:20:37Z")

</div>

Hi,  
Under Centos 7 Apache servers we are directing Custom log through logger below is config in httpd.conf

```auto
RemoteIPHeader X-Forwarded-For
LogFormat "%v %a %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

ErrorLog "|/usr/bin/logger -t httpd_error -p local5.info"
CustomLog "|/usr/bin/logger -t httpd_access -p local5.info" combined

```

and config for rsyslog file /etc/rsyslog.d/httpd.conf is below

```auto
:syslogtag, isequal, "httpd_error:" -/var/log/httpd/error_log
& ~
:syslogtag, isequal, "httpd_access:" -/var/log/httpd/access_log
& ~

```

Same config not working in Rocky 8. Apache stop putting any log in access\_log or error\_log file once we do enable this custom config in httpd.conf .

---

<div class="post-metadata">

**Author:** ![iwalker](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/iwalker/32/2599_2.png) [@iwalker](https://forums.rockylinux.org/u/iwalker)\
**Post date:** [June 1, 2022, 12:30pm UTC](https://forums.rockylinux.org/t/apache-custom-log-through-logger-not-working/6226/2 "2022-06-01T12:30:02Z")

</div>

I’m finding it difficult to understand why you are sending it through logger instead of just doing:

```auto
ErrorLog /var/log/httpd/error_log
CustomLog /var/log/httpd/access_log combined

```

which would send it direct to /var/log/httpd instead of having to jump through something else first. I guess you have a reason for it and maybe you can explain why you are doing it that way instead of the default way of how logging with Apache works?

However, maybe it’s not working due to selinux perhaps?

---

<div class="post-metadata">

**Author:** ![linuxlover](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/linuxlover/32/2227_2.png) [@linuxlover](https://forums.rockylinux.org/u/linuxlover)\
**Post date:** [June 2, 2022, 11:03am UTC](https://forums.rockylinux.org/t/apache-custom-log-through-logger-not-working/6226/3 "2022-06-02T11:03:53Z")

</div>

Hi iwalker ,

After some deep analysis , I able to identify and fix the issue. Let me explain thing in 3 parts

**Why are using logger in Apache ?**

we are using a centralized Syslog sever. All servers sending logs to this syslog. and syslog based on Rsyslog Template ( hostname , programname etc ) it is putting logs in different files under hostname

below is rsyslog.conf config.

```auto
$template RemoteLogs,"/data/%HOSTNAME%/%PROGRAMNAME%.log"
*.* ?RemoteLogs

```

After adding tag by logger in apache , server local syslog sending all apache logs to remote syslog

like  
_._ @10.X.X.X.X:51X

Now these logs required on local server also. So below config is defined to log it local machine

```auto
:syslogtag, isequal, "httpd_error:" -/var/log/httpd24/error_log
& ~
:syslogtag, isequal, "httpd_access:" -/var/log/httpd24/access_log
& ~

```

**Why logs were not receiving locally in Rocky 8 ?**

On Centos 7 every thing is working fine. On Rocky 8 while sending the logs , PID was added with tag like below is the log recieving on Syslog server for Rocky 8

```auto
2022-06-02T14:45:07+04:00 SC2-XXX httpd_access[*483157*]: Default 10.XXXX - - [02/Jun/2022:14:45:07 +0400] "GET /index.html HTTP/1.1" 200 - "-" "ELB-HealthChecker/2.0"

```

Due to this PID , isequal condition was not fulfilling to store the logs local

**How fixed the issue ?**

I changed the compare-operations from isequal to contains. After putting below configuration every thing is working fine.

```auto
syslogtag, contains, "httpd_error" -/var/log/httpd/error_log
& stop
:syslogtag, contains, "httpd_access" -/var/log/httpd/access_log
& stop

```

---

<div class="post-metadata">

**Author:** ![brian](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/brian/32/5777_2.png) [@brian](https://forums.rockylinux.org/u/brian)\
**Post date:** [August 25, 2023, 3:48am UTC](https://forums.rockylinux.org/t/apache-custom-log-through-logger-not-working/6226/4 "2023-08-25T03:48:15Z")

</div>


