Skip to content

Instantly share code, notes, and snippets.

@nolili
Created November 18, 2012 08:33
Show Gist options
  • Save nolili/4104270 to your computer and use it in GitHub Desktop.
Save nolili/4104270 to your computer and use it in GitHub Desktop.
NSLogの情報をサンドボックスにテキストファイルとして書き出す
- (void) redirectConsoleLogToDocumentFolder
{
//ログを出力する
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *logPath = [documentsDirectory stringByAppendingPathComponent:@"console.log"];
freopen([logPath cStringUsingEncoding:NSASCIIStringEncoding],"a+",stderr);
NSLog(@"Start Logging");
//バージョン情報をログに出力
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
NSLog(@"Bundle Version : %@",version);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment