• 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
Re: Logging to text files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Logging to text files


  • Subject: Re: Logging to text files
  • From: email@hidden (Tom Marchand)
  • Date: Thu, 05 Jul 2007 17:51:22 +0000

If you don't want to code this, you can achieve the same functionally at the command line:

Command 2</tmp/redirect.log

Of course this will only be useful in a development environment.


 -------------- Original message ----------------------
From: "Tom Harrington" <email@hidden>
> On 7/5/07, Devraj Mukherjee <email@hidden> wrote:
> > Hi everyone,
> >
> > Can NSLog  be used to write a Log file?
>
> Yes-- with a little setup.  NSLog writes to stderr, so if you redirect
> stderr, you redirect NSLog.
>
> The basic setup is:
>
> 	FILE *newStderr = freopen("/tmp/redirect.log", "a", stderr);
> 	NSLog(@"Test NSLog");
>
> You should probably call umask() before redirecting with whatever mask
> you want.  The above will redirect all NSLog calls.  If you wanted to
> later restore normal NSLog behavior, a little work with dup() and
> dup2() would do the trick of saving and restoring the file handle.
>
> --
> Tom Harrington
> email@hidden
> AIM: atomicbird1
> _______________________________________________
>
> 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

_______________________________________________

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

  • Prev by Date: Zombies don't get enabled
  • Next by Date: Re: Zombies don't get enabled
  • Previous by thread: Re: Logging to text files
  • Next by thread: Adding metadata to images
  • Index(es):
    • Date
    • Thread