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
    • 983
    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                           

You must be logged in to access this page

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

You must be logged in to access this page

Reset Password
Fill out the form below and reset your password:

You must be logged in to access this page