'Core log Lua in Haproxy does not log to the default haproxy log file

I have setup a Lua script to process the request in HAProxy. I am using Core class to log information in the log file.

Here is my config file

sudo nano /etc/haproxy/haproxy.cfg

global
        lua-load /etc/haproxy/route_req.lua
        log /dev/log local0
        log /dev/log local1 notice
        chroot /var/lib/haproxy
        stats timeout 30s
        user haproxy
        group haproxy
        daemon

#HAProxy for web servers
frontend web-frontend
  bind 10.122.0.2:80
  bind 139.59.75.106:80
  mode http
  use_backend %[lua.routeIP]

Here is my route_req.lua file

local function getIP(txn)
        local clientip = txn.f:src()
        backend = ""
        -- MY CODE GOES HERE
        core.log(core.info, "This is an example\n")

        return backend
end

core.register_fetches('routeIP', getIP)

I don't see any logging in my log file, /var/log/haproxy.log. Also there was no logging regarding the same in /var/log/syslog file.



Solution 1:[1]

Make sure to include log global in your frontend stanza.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Josh