Good morning,
I currently have a dynamic vhost configuration and I'm looking a way to set custom log path per domain. Currently, I tried to set a variable as error_log path and tried to change it within access_by_lua but it doesn't work.
Is there any way to achieve it?

    18 days later
    access_log  "logs/$http_host.log"  main;

    I have the above config, and it works.
    Make sure the worker process has permission to create/write file in logs directory.

      a month later

      Hello,
      Digging deeper made be found that if I put only variable, nginx consider it as relative path, even if it is an absolute path.

      So,

      set $accesslog "/home/website1/error.log";
      access_log $accesslog main;

      is not working (it leads to /usr/local/openresty/nginx/home/website1/error.log), but

      set $accesslog "website1/error.log";
      access_log /home/$accesslog main;

      is working.

        8 days later

        Is there any log in the error log file when it is not working?

          Write a Reply...