# Problem with logging

**URL:** <https://discourse.haproxy.org/t/problem-with-logging/3739>\
**Category:** Help!\
**Created:** [April 18, 2019, 7:28am UTC](https://discourse.haproxy.org/t/problem-with-logging/3739 "2019-04-18T07:28:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gdevelek](https://avatars.discourse-cdn.com/v4/letter/g/46a35a/32.png) [@gdevelek](https://discourse.haproxy.org/u/gdevelek)\
**Post date:** [April 18, 2019, 7:28am UTC](https://discourse.haproxy.org/t/problem-with-logging/3739/1 "2019-04-18T07:28:23Z")

</div>

Greetings,

My HAProxy 1.8.19 on Debian-9 is logging starts and stops but not traffic. Using the logger tool I can log anything I want to the proper files, so I can’t figure out what’s wrong.

Here is my logging config for rsyslog, saved in `/etc/rsyslog.d/haproxy.conf`.

Thanks for any clues!

$ModLoad imudp  
$UDPServerAddress 127.0.0.1  
$UDPServerRun 514  
$FileOwner dialog  
$FileGroup dialog  
$FileCreateMode 0644

local0.\* -/home/dialog/HAPROXY/logs/haproxy-traffic.log  
local0.notice -/home/dialog/HAPROXY/logs/haproxy-admin.log  
local0.info -/home/dialog/HAPROXY/logs/haproxy-info.log

…and here is the HAProxy config:

global  
daemon  
maxconn 256  
log 127.0.0.1:514 local0

defaults  
log global  
option tcplog  
mode tcp  
timeout connect 5000ms  
timeout client 50000ms  
timeout server 50000ms

frontend fr\_server1  
log 127.0.0.1:514 local0  
bind 0.0.0.0:8000  
default\_backend bk\_server1

backend bk\_server1  
log 127.0.0.1:514 local0  
server srv1 10.1.1.184:2775 maxconn 2048

---

<div class="post-metadata">

**Author:** ![ciprian.craciun](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/ciprian.craciun/32/722_2.png) [@ciprian.craciun](https://discourse.haproxy.org/u/ciprian.craciun)\
**Post date:** [April 21, 2019, 7:12am UTC](https://discourse.haproxy.org/t/problem-with-logging/3739/2 "2019-04-21T07:12:10Z")

</div>

From what I know HAProxy logs connections / requests only after they end, therefore you should see a log line only after the connection was closed.

However you could try to use `log global` also in the frontend / backend, (although it shouldn’t make a difference). Also check Rsyslog own logs as perhaps it doesn’t understand the syslog protocol version HAProxy is sending (there are two versions RFC-3164 and RFC-5424).

* * *

Looking through some of my old HAProxy configuration files, this is how I configured them at that time (it is using Rsyslog):

```auto
log /dev/log len 65535 format rfc3164 daemon info err
# do not set log-send-hostname and log-tag

```

And for Rsyslog:

```auto
template(name="haproxy_log_file" type="string"
    string="/var/logs/haproxy/%timereported:1:10:date-rfc3339%.log")

template(name="haproxy_log_file_err" type="string"
    string="/var/logs/haproxy/%timereported:1:10:date-rfc3339%.err.log")

template(name="haproxy_log_line" type="string"
    string="<< %timereported:::date-rfc3339% %syslogseverity-text% >> %msg%\n")

ruleset(name="haproxy_rules") {

    action(
        type="omfile"
        dynaFile="haproxy_log_file"
        template="haproxy_log_line"
        fileOwner="syslog" fileGroup="haproxy" fileCreateMode="0640"
        dirOwner="syslog" dirGroup="haproxy" dirCreateMode="0750" createDirs="off"
        sync="off" ioBufferSize="128k" flushOnTXEnd="on" dynaFileCacheSize="2")

    if prifilt("*.err") then
        action(
            type="omfile"
            dynaFile="haproxy_log_file_err"
            template="haproxy_log_line"
            fileOwner="syslog" fileGroup="haproxy" fileCreateMode="0640"
            dirOwner="syslog" dirGroup="haproxy" dirCreateMode="0750" createDirs="off"
            sync="on" ioBufferSize="128k" flushOnTXEnd="on" dynaFileCacheSize="2")

    stop
}

input(type="imuxsock"
    socket="/var/lib/haproxy/dev/log"
    createPath="on" unlink="on"
    ignoreTimestamp="off" useSysTimeStamp="on"
)

if ($programname == "haproxy") then call haproxy_rules
& stop

```
