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
    • 777
    Comment on it

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

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

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

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