I also wanted to do this, but apparently by design nginx cannot expand the variables in the error_log command if there are errors, and it cannot get the log file name to write them.
Their suggestion is to use some program to generate your configuration files. You can use sed to do this, to automatically search for and replace your own variables and place the output in the nginx configuration directory.
Malvineous
source share