You are not logged in.

#1 2014-03-30 23:49:24

ioquatix
Member
Registered: 2014-03-30
Posts: 18

Nginx logging to journalctl

Hi,

I'm using passenger/nginx, installed using the `passenger-install-nginx-module` and I'm wondering how I connect this to journalctl for logging? I am currently logging to a file, e.g.

    access_log logs/access.log combined;

Thanks
Samuel

Offline

#2 2014-03-31 00:14:48

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: Nginx logging to journalctl

What's the 'passenger-install-nginx-module'? How did you install it? How does it differ from the nginx package in the Arch repos? Actually, why aren't you using the nginx package in the Arch repos?

Offline

#3 2014-03-31 00:22:56

ioquatix
Member
Registered: 2014-03-30
Posts: 18

Re: Nginx logging to journalctl

`passenger-install-nginx-module` is a script which installs passenger and nginx on (almost) any system (e.g. available in the community/passenger package). I've used it frequently in the past. I'm considering using the arch package for nginx, but haven't had a chance to look into it.

In any case, how does one output logging messages to journalctl? e.g. how does Apache do it?

Offline

#4 2014-03-31 00:44:49

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: Nginx logging to journalctl

How do you run nginx, after installing it with this script, instead of with pacman?

Offline

#5 2014-03-31 00:45:29

ioquatix
Member
Registered: 2014-03-30
Posts: 18

Re: Nginx logging to journalctl

Just the same way, with a service:

[Unit]
Description=A high performance web server and a reverse proxy server
After=syslog.target network.target

[Service]
Type=forking
SyslogIdentifier=nginx
PIDFile=/opt/nginx/logs/nginx.pid
ExecStartPre=/opt/nginx/sbin/nginx -t
ExecStart=/opt/nginx/sbin/nginx
ExecReload=/opt/nginx/sbin/nginx -s reload
ExecStop=/opt/nginx/sbin/nginx -s stop

[Install]
WantedBy=multi-user.target

Offline

#6 2014-03-31 00:52:56

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: Nginx logging to journalctl

OK - and there's nothing in the journal about it? What does 'systemctl status nginx' show? (I'm assuming that file you just posted is called nginx.service).

Offline

#7 2014-03-31 00:54:12

ioquatix
Member
Registered: 2014-03-30
Posts: 18

Re: Nginx logging to journalctl

Yeah, the log files have entries (e.g. access log), but the journal just contains general crap:

# systemctl status nginx
nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/etc/systemd/system/nginx.service; enabled)
   Active: active (running) since Mon 2014-03-31 13:33:00 NZDT; 21min ago
  Process: 29113 ExecStop=/opt/nginx/sbin/nginx -s stop (code=exited, status=0/SUCCESS)
  Process: 29142 ExecStart=/opt/nginx/sbin/nginx (code=exited, status=0/SUCCESS)
  Process: 29123 ExecStartPre=/opt/nginx/sbin/nginx -t (code=exited, status=0/SUCCESS)
Main PID: 29162 (nginx)
   CGroup: /system.slice/nginx.service
           |-29144 PassengerWatchdog
           |-29147 PassengerHelperAgent
           |-29152 PassengerLoggingAgent
           |-29162 nginx: master process /opt/nginx/sbin/nginx
           |-29163 nginx: worker process
           |-29164 nginx: worker process
           |-29165 nginx: worker process
           `-29166 nginx: worker process

Mar 31 13:33:00 primary.foobar.co.nz nginx[29123]: nginx: the configuration file /opt/nginx/conf/nginx.conf syntax is ok
Mar 31 13:33:00 primary.foobar.co.nz nginx[29123]: nginx: configuration file /opt/nginx/conf/nginx.conf test is successful
Mar 31 13:33:00 primary.foobar.co.nz systemd[1]: Failed to read PID from file /opt/nginx/logs/nginx.pid: Invalid argument
Mar 31 13:33:00 primary.foobar.co.nz systemd[1]: Started A high performance web server and a reverse proxy server.

Offline

#8 2014-03-31 01:02:01

ioquatix
Member
Registered: 2014-03-30
Posts: 18

Re: Nginx logging to journalctl

In any case, even if I can't log to journald, what is the best way to rotate the log files in archlinux?

EDIT: Okay, duh, installed logrotate, got that working fine - so I guess the real issue here is: what is the preferred way to migrate legacy daemons to use journald, (e.g. processes which have log files traditionally)?

Last edited by ioquatix (2014-03-31 01:59:55)

Offline

Board footer

Powered by FluxBB