I would like to redirect NSog()
to file, but still to see the output in console.
I am aware that stderr
can be redirected to file using:
According to the docs, you will need a custom log facility.
You need at a minimum, a function that takes variadic arguments and printd to NSLog and fprintf, something like:
void myLog(NSString* format, ...)
{
va_list argList;
va_start(argList, format);
NSString* formattedMessage = [[NSString alloc] initWithFormat: format arguments: argList];
va_end(argList);
NSLog(@"%@", formattedMessage);
fprintf(myFileDescriptor, "%s\n", [formattedMessage UTF8String]);
[formattedMessage release]; // if not on ARC
}
Or there are Cocoa logging frameworks.
Looking for a Specific Cocoa Logging Framework