I\'m following the suggestion in the answer here for redirecting NSLog output on an iOS device to a file, which works great. The problem is that it no longer shows up in the co
Or you can redirect to a TCP socket and view on a remote telnet client. No need for XCode this way!
Basically:
Create a standard C function which calls an Obj-C static method:
void tcpLogg_log(NSString* fmt, ...) { va_list args; va_start(args, fmt); [TCPLogger tcpLog:fmt :args]; va_end(args); }
The static Obj-C method:
(void)tcpLog:(NSString*)fmt :(va_list)args { NSLogv(fmt, args);}if(sharedSingleton != nil && sharedSingleton.socket != nil) { NSString *time = [sharedSingleton.dateFormat stringFromDate:[NSDate date]]; NSString *msg = [[NSString alloc] initWithFormat:fmt arguments:args]; mach_port_t tid = pthread_mach_thread_np(pthread_self()); NSString *str = [NSString stringWithFormat:@"%@[%X]: %@\r\n", time, tid, msg]; NSData *data = [str dataUsingEncoding:NSUTF8StringEncoding]; [sharedSingleton.socket writeData:data withTimeout:NETWORK_CLIENT_TIMEOUT_PERIOD tag:0]; }
Then in your .pch file, add the following lines to override NSLog()
define NSLog(...) tcpLogg_log(__VA_ARGS__); void tcpLogg_log(NSString* fmt, ...);
Of course more details are required to handle the TCP Socket. Working source code is available here: https://github.com/driedler/iOS-TCP-Logger/wiki/About