discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSLog suddenly mirroring to /var/log/user.log, /var/log/warnings, and /v


From: Lobron, David
Subject: NSLog suddenly mirroring to /var/log/user.log, /var/log/warnings, and /var/log/syslog
Date: Thu, 4 Aug 2016 14:16:29 +0000

Hi All,

I have an application that sends NSLog output to a custom location.  A few days 
ago, the log lines suddenly started mirroring to /var/log/user.log, 
/var/log/warnings, and /var/log/syslog.  I did not make any changes to my 
program or the GNUStep runtime.  From a read of the NSLog docs, it seems like 
this should not be able to happen.  Has anyone seen this before?  

My code sets up logging in a function called p_logRotate.  This function is 
called when the application starts up, and also when its regular log file needs 
to be rotated: the latter is triggered by a SIGHUP from a monitoring process.  
This code has been in use at my company for years, across many programs, so I'd 
be surprised if a bug like this suddenly was triggered.  The only thing that 
distinguishes my application from others is that it's doing very heavy logging 
at the moment.  Also, /var is currently full, but that's a result of these logs 
being mirrored to /var/log/* - I don't think it's the cause. 

Many thanks in advance for any help here.

--David

My code:

- (void)p_logRotate:(BOOL)firstTime
{
    if (!firstTime)
        NSLog(@"Rotating log file");
    if (_logfileNameCString != 0) {
        int fd;
        fd = open(_logfileNameCString, O_WRONLY|O_CREAT|O_APPEND, 
S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
        if (fd >= 0) {
            if (firstTime)
                NSLog(@"Logging to %@", _logfileName);
            dup2(fd, STDOUT_FILENO);
            dup2(fd, STDERR_FILENO);
            close(fd);
            [[NSNotificationCenter defaultCenter] 
postNotificationName:AkamaiDaemonLogFileWasOpenedNotification object:self];
        } else {
            [NSException raise:@"log rotate failed" format:@"log rotation 
failed: %s", strerror(errno)];
        }
    }
    if (!firstTime) {
        NSLog(@"Log file rotated");
        [[NSNotificationCenter defaultCenter] 
postNotificationName:AkamaiDaemonLogFileWasRotatedNotification object:self];
    }
} 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]