Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forwarding Nginx logs to docker #111

Closed
kswope opened this issue Oct 11, 2015 · 9 comments
Closed

Forwarding Nginx logs to docker #111

kswope opened this issue Oct 11, 2015 · 9 comments

Comments

@kswope
Copy link

kswope commented Oct 11, 2015

I see that the crond is running and logrotate is set up to rotate the nginx logs and thats all good but in a container shouldn't the logging be redirected to stdout and stderror?

I'm using the 12factor gem to redirect rails logs to stdout and stderr but what about the nginx logs?

I'm not sure but I think nginx also logs stderr of a subprocess to error.log

This is all very confusing and I think there should be some info about it in the README

I'm also trying this, any better ideas?

RUN ln -sf /dev/stdout /var/log/nginx/access.log                                                                                                
RUN ln -sf /dev/stderr /var/log/nginx/error.log 

[EDIT]

There's also http://nginx.org/en/docs/ngx_core_module.html#error_log but I'm not seeing anything for access logs.

@kswope
Copy link
Author

kswope commented Oct 11, 2015

Ahah below forwards the nginx logs to docker and is already enabled, thanks!

But what about access logs? There is definitely nothing forwarding them to docker, and removing access_log from nging.conf doesn't cause it to start writing to stdout. All I've got so far is
ln -sf /dev/stdout /var/log/nginx/access.log

rails_12factor takes care of rails logging to docker because it outputs to stdout

> more /etc/service/nginx-log-forwarder/run 

#!/bin/bash
# Forwards the Nginx error.log to the Docker logs.
set -e
if [[ -e /var/log/nginx/error.log ]]; then
        exec tail -F /var/log/nginx/error.log
else
        exec sleep 10
fi

@FooBarWidget
Copy link
Member

Access logs aren't being forwarded right now. Maybe we should do that in the next version.

@shaneog
Copy link

shaneog commented Jan 5, 2016

I'd also like to see a recommended access logging strategy

@anlek
Copy link

anlek commented Jan 20, 2016

I'd like to know how to stop nginx access log forwarding (in development)

@jeffbyrnes
Copy link

Myself and @andrhamm are running into an issue where, with the logging set up like so:

config.logger = ::Logger.new(STDOUT)

# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new

We end up with log messages like so:

App 172 stdout: I, [2016-07-08T14:19:35.607941 #172]  INFO -- Status: 200

That App 172 stdout: bit is being appended, and we do not want it. Where is it coming from? Passenger? Docker?

@FooBarWidget
Copy link
Member

@jeffbyrnes It's coming from Passenger. This is currently non-configurable.

@jeffbyrnes
Copy link

@FooBarWidget thanks for confirming that.

@shaneog
Copy link

shaneog commented Sep 19, 2016

@FooBarWidget Is this logging (App X stdout:) still non-configurable?
My app logs in JSON and the Docker logs are picked up by logstash. This output breaks my logging environment.
I am using Passenger Standalone in Docker.

@OnixGH OnixGH changed the title logging strategy? Forwarding Nginx logs to docker Jun 15, 2017
@OnixGH
Copy link
Contributor

OnixGH commented Jun 15, 2017

For questions / remarks about Passenger features please refer to the Passenger community support forum or the Passenger issue list.

The original question about log forwarding is answered, and I've split the enhancement request for access logging to #189.

@OnixGH OnixGH closed this as completed Jun 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants