Re: Redirect NSLog to stdout?
Re: Redirect NSLog to stdout?
- Subject: Re: Redirect NSLog to stdout?
- From: Butch Anton <email@hidden>
- Date: Tue, 29 Jun 2010 13:25:22 -0700
- Thread-topic: Redirect NSLog to stdout?
On 6/29/10 7:09 AM, "Tito Ciuro" <email@hidden> wrote:
[snip]
> I don't really like it, since this forces me to use NSLogOut() everywhere...
> which kinda sucks. Instead, is there a way to configure NSLog() so that it
> redirects to stdout instead of stderr?
Lifted from http://cocoaheads.byu.edu/wiki/different-nslog:
Redirected NSLog()
Occasionally, you may want to redirect your NSLog() output to a file so that
you can examine it more conveniently. NSLog() works by outputting messages
to STDERR, so all you need to do is redirect the STDERR stream to a file,
and you're good to go. The following code will redirect it to a file on your
desktop:
int fd = creat ("/Users/dave/Desktop/my_log", S_IRUSR | S_IWUSR | S_IRGRP |
S_IROTH);
close (STDERR_FILENO);
dup (fd);
close (fd);
NSLog(@"this will be written to my_log");
This will only affect NSLog() calls from your application.
Butch Anton
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