• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Problem redirecting NSLog() output to stderr
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem redirecting NSLog() output to stderr


  • Subject: Problem redirecting NSLog() output to stderr
  • From: "email@hidden" <email@hidden>
  • Date: Sun, 17 Aug 2008 22:10:18 +0100

Hello List

My app consists of a GUI process, a daemon and a number of worker processes.
Each of these processes has their stderr redirected via freopen() to the same log file.
For the purposes of simple logging this arrangement works acceptably.
There is a thread on why this should be: http://www.cocoabuilder.com/archive/message/cocoa/2003/6/16/3689


The user may however delete the shared log from the GUI.
After this the daemon and worker process log output is lost.
In those cases can I detect that the stderr stream is no longer valid?

I have tried fcntl(), fileno(), fstat(), ftell() and feof() without success.

My actual call to NSLog() is wrapped in a generic logging class.
My only solution so far is to issue freopen(logfile, "a", stderr) prior to each and every call to NSLog().
But this seems brutal.


Jonathan
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Problem redirecting NSLog() output to stderr
      • From: "Michael Ash" <email@hidden>
  • Prev by Date: Re: setNilValueForKey: not called when Number Formatter is nil
  • Next by Date: Re: building a command-line tool as a bundle
  • Previous by thread: Re: How to enumerate directory contents?
  • Next by thread: Re: Problem redirecting NSLog() output to stderr
  • Index(es):
    • Date
    • Thread