Feature Request for access_log stdout;

Aleksandar Lazic al-nginx at none.at
Wed Feb 17 19:04:45 UTC 2016


Hi.

Am 17-02-2016 16:47, schrieb Valentin V. Bartenev:
> On Wednesday 17 February 2016 16:26:01 Aleksandar Lazic wrote:
>> Hi.
>> 
>> how difficult is it to be able to add "access_log stdout;" to nginx,
>> similar like "error_log stderr;"?
>> 
>> I ask because in some PaaS environment is it difficult to setup a
>> dedicated user yust for nginx.
>> 
>> It fits also a little bit better to http://12factor.net/logs
>> 
> [..]
> 
> What's the problem with "access_log /dev/stdout"?

Well I have the following problem on openshift v3.

#######
nginx: [alert] could not open error log file: open() 
"/var/log/nginx/error.log" failed (13: Permission denied)
2016/02/17 18:34:32 [warn] 1#1: the "user" directive makes sense only if 
the master process runs with super-user privileges, ignored in 
/etc/nginx/nginx.conf:2
2016/02/17 18:34:32 [emerg] 1#1: open() "/dev/stdout" failed (13: 
Permission denied)

I have no name!@nginx-test-8-emwut:/$
I have no name!@nginx-test-8-emwut:/$ ls -la /dev/stdout
lrwxrwxrwx. 1 root root 15 Feb 17 18:24 /dev/stdout -> /proc/self/fd/1
I have no name!@nginx-test-8-emwut:/$ id
uid=1000550000 gid=0(root) groups=0(root)
#######

The config file is this
######
user  nginx;
worker_processes  1;

error_log stderr warn;
pid /tmp/nginx.pid;


events {
     worker_connections  1024;
}


http {
     include       /etc/nginx/mime.types;
     default_type  application/octet-stream;

     log_format  main  '$remote_addr - $remote_user [$time_local] 
"$request" '
                       '$status $body_bytes_sent "$http_referer" '
                       '"$http_user_agent" "$http_x_forwarded_for"';

     access_log /dev/stdout;

     sendfile        on;
     #tcp_nopush     on;

     keepalive_timeout  65;

     #gzip  on;

     include /etc/nginx/conf.d/*.conf;
}
##########

The difficulty is that the build and run setup differs in that case that 
you are root at build time but any arbitrary user at runtime.

Here some more details.

https://docs.openshift.com/enterprise/3.1/creating_images/guidelines.html#use-uid

In case you have a openshift running you can use this repo for testing.

https://github.com/git001/nginx-osev3


> Please note that writing logs to stdout can be a bottleneck, or cause 
> nginx
> to stuck.  The "error_log stderr;" exists mostly for development 
> purposes.

Thanks for tip.
I remember that 'daemon off' have the same background ;-)

br Aleks



More information about the nginx mailing list