LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 09-13-2010, 02:14 AM   #1
doru
Member
 
Registered: Sep 2008
Distribution: Ubuntu 8.04 LTS Server
Posts: 85

Rep: Reputation: 16
syslog stops writing in log


syslog stops writing immediately after log rotation, after I start the system (but not after reboot), and at some other times, into my fast cgi application's log. It starts working after /etc/init.d/sysklogd restart. Please give me any hint.


Configuration:

I am using Ubuntu 8.04 lts server, Apache web server.

My (fast cgi) application uses:
Code:
#include <syslog.h>
syslog(LOG_LOCAL6|LOG_INFO, "new n= %d;\n", count);
to log some activity messages.
At the end of /etc/syslog.conf I added:
Code:
local6.=info -/var/log/apache2/myapp.log
In /etc/syslog.conf I added to each selector which contained "myapp.log":
Code:
;local6.!=info
like this:
Code:
*.*;auth,authpriv.none;local6.!=info            -/var/log/syslog
and:
Code:
*.=info;*.=notice;*.=warn;\
         auth,authpriv.none;\
         cron,daemon.none;\
         mail,news.none;local6.!=info            -/var/log/messages

Last edited by doru; 09-13-2010 at 02:22 AM.
 
Old 09-16-2010, 03:08 AM   #2
doru
Member
 
Registered: Sep 2008
Distribution: Ubuntu 8.04 LTS Server
Posts: 85

Original Poster
Rep: Reputation: 16
It seems that syslog ceases to function when syslogd is restarted automatically. This happens when I start or reboot the computer and when logs are rotated. After I:
Code:
/etc/init.d/sysklogd restart
it all goes well. This is true for my fcgi application only, other system pre-configured logs work fine.

fflush(NULL); and closelog(); do not seem to make any difference.

I was amazed today to discover that:
Code:
wget localhost/myapp.fcgi?some%20data
issued locally as root is logged well after I started the system, but access requests from other locations were not logged unless I did /etc/init.d/sysklogd restart.

And this is also a BUMP.

Doru
 
Old 09-17-2010, 03:20 AM   #3
doru
Member
 
Registered: Sep 2008
Distribution: Ubuntu 8.04 LTS Server
Posts: 85

Original Poster
Rep: Reputation: 16
I modified:
/etc/init.d/sysklogd reload-or-restart > /dev/null
into:
/etc/init.d/sysklogd restart > /dev/null
in:
/etc/cron.{weekly,daily}/sysklogd

and now I got it going, I believe. However, I don't like this solution, because I don't know what is going on here.

Other people have got the same problem:
http://www.linuxquestions.org/questi...8-04-a-703386/

Doru
 
Old 09-19-2010, 11:31 PM   #4
doru
Member
 
Registered: Sep 2008
Distribution: Ubuntu 8.04 LTS Server
Posts: 85

Original Poster
Rep: Reputation: 16
The solution in my last post seems to be working. It works after the daily rotation. Thank you, Doru!

Doru
 
Old 09-19-2012, 10:12 AM   #5
doru
Member
 
Registered: Sep 2008
Distribution: Ubuntu 8.04 LTS Server
Posts: 85

Original Poster
Rep: Reputation: 16
In short, I print into some /var/log/apache2/myapp.log file from a fcgi application under apache. You can see the configuration changes which I performed in the first post.

As a result:
in /etc/cron.daily/sysklogd:
Code:
/etc/init.d/sysklogd reload-or-restart > /dev/null
calls:
in /etc/init.d/sysklogd:
Code:
sudo start-stop-daemon --stop --quiet --signal 1 --pidfile /var/run/syslogd.pid --name syslogd
and myapp.fcgi stops writing to myapp.log and it stays like that.

I changed:
in /etc/cron.daily/sysklogd:
Code:
/etc/init.d/sysklogd restart > /dev/null
and now:
Code:
sudo logrotate -f /etc/logrotate.conf
restarts all apache2 processes excepting one and kills myapp.fcgi.

It appears that the combination of apache2, fcgi and syslog makes a perfect mess of my logging. Of course, all system and apache2 native logging works flawlessly. Anybody with some experience in linux, please give me any advice. Do I have a chance to solve this?
 
Old 09-23-2012, 11:53 AM   #6
doru
Member
 
Registered: Sep 2008
Distribution: Ubuntu 8.04 LTS Server
Posts: 85

Original Poster
Rep: Reputation: 16
Continued here: http://mailman.fastcgi.com/pipermail...er/000744.html
 
Old 09-24-2012, 09:42 AM   #7
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 11.4
Posts: 1,319

Rep: Reputation: 252Reputation: 252Reputation: 252
I would suggest to use the system logging facility in your myapp.fcgi and combine the two sources in the syslog facility you use.
 
Old 10-03-2012, 06:48 AM   #8
doru
Member
 
Registered: Sep 2008
Distribution: Ubuntu 8.04 LTS Server
Posts: 85

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by Reuti View Post
I would suggest to use the system logging facility in your myapp.fcgi and combine the two sources in the syslog facility you use.
Thank you for your answer.

Am I not using the system logging facility already, since I call syslog?

I don't understand what two sources in the syslog facility should I combine? I call syslog from myapp.fcgi, in C++.
 
Old 10-11-2012, 11:27 AM   #9
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 11.4
Posts: 1,319

Rep: Reputation: 252Reputation: 252Reputation: 252
I’m quite confused what I had in mind too. What is your definition for the logrotation of the log files in /etc/logrotate.d.
 
Old 11-07-2012, 06:15 AM   #10
doru
Member
 
Registered: Sep 2008
Distribution: Ubuntu 8.04 LTS Server
Posts: 85

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by Reuti View Post
I’m quite confused what I had in mind too. What is your definition for the logrotation of the log files in /etc/logrotate.d.
Code:
/etc/logrotate.d$ cat apache2
/var/log/apache2/*.log {
        weekly
        missingok
        rotate 52
        compress
        delaycompress
        notifempty
        create 640 root adm
        sharedscripts
        postrotate
                if [ -f "`. /etc/apache2/envvars ; echo ${APACHE_PID_FILE:-/var/run/apache2.pid}`" ]; then
                        /etc/init.d/apache2 reload > /dev/null
                fi
        endscript
}
To summarize my two problems, with solutions at the end of each problem description:

Quote:
in /etc/cron.{daily,weekly}/sysklogd (the original):
/etc/init.d/sysklogd reload-or-restart > /dev/null
in /etc/init.d/sysklogd
sudo start-stop-daemon --stop --quiet --signal 1 --pidfile /var/run/syslogd.pid --name syslogd
prevents myapp.fcgi from writing into myapp.log any longer (but access.log is still written), even if you do sudo start-stop-daemon --start --quiet --pidfile /var/run/syslogd.pid --name syslogd --startas /sbin/syslogd, which anyway is not done in the script.
in /etc/cron.{daily,weekly}/sysklogd I did:
/etc/init.d/sysklogd restart > /dev/null

in /etc/cron.daily/logrotate:
sudo logrotate -f /etc/logrotate.conf restarts all apache processes excepting one and kills myapp.fcgi. It changes permissions of myapp.log into root.adm, which are corrected back into syslog.adm in /etc/cron.daily/sysklogd by /etc/init.d/sysklogd restart. The correction takes place in /etc/init.d/sysklogd. In the meantime, myapp.fcgi can not write into myapp.log.
in /etc/cron.daily/logrotate I did:
if ! ps -A | grep fcgi > /dev/null; then
/usr/sbin/logrotate /etc/logrotate.conf; fi
to rotate only when no fcgi process is running.

the other solution to the second problem, to catch the termination signal in myapp.fcgi and to save the state such that later I can restore it when myapp.fcgi is restarted, could still lose one or more access requests and it requires too much work. Plus, it would have to be done for all fcgi's.

Last edited by doru; 11-07-2012 at 06:18 AM.
 
  


Reply

Tags
sysklogd, syslog


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
syslog-ng stops logging eentonig Linux - Server 2 04-23-2010 09:51 AM
How to change Debian log rotation of syslog and daemon.log onmountain Linux - Newbie 2 07-31-2008 02:27 AM
I need help getting syslog to log remotely, this is just the regular syslog. abefroman Linux - Software 2 06-05-2008 11:36 AM
stop popa3d from writing to syslog? fmillion Linux - Server 1 02-24-2008 01:28 PM
syslog client to log to syslog-ng and itself noir911 Linux - Server 1 02-08-2008 09:51 AM


All times are GMT -5. The time now is 06:14 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration