Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to redirect console logs to a file

    • 0
    • 1
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 747
    Comment on it

    To redirect the log statements to a file instead of console call the following function at the start of function applicationDidFinishLaunching.

    - (void)redirectConsoleLogToDocumentFolder
    {
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
                                                             NSUserDomainMask, YES);
        NSString *documentsDirectory = [paths objectAtIndex:0];
        NSString *logPath = [documentsDirectory stringByAppendingPathComponent: @"filename.log"];
        freopen([logPath fileSystemRepresentation],"a+",stderr);
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: