In iOS10 the NSlog are limited to 1024 characters has anybody know a workaround to print complete string.
Asked
Active
Viewed 2,972 times
7
-
split string into 1024 char chunks and log each one individually. – Marc B Sep 16 '16 at 18:50
-
1solution is good, but its seems to be hard to implement, as we use lot of logs. Especially the server response are huge and it would be good to log JSON without line breaks. – Naveen Shan Sep 16 '16 at 18:53
3 Answers
6
try printf
then instead of NSLog
like,
printf("%s", [string UTF8String]);
It may works

Ketan Parmar
- 27,092
- 9
- 50
- 75
-
NSString *logMessage = [NSString stringWithFormat:@"
"]; printf("%s",[logMessage UTF8String]); – Naveen Shan Sep 16 '16 at 19:06
3
I thinks this is a same question with [ NSLog on devices in iOS 10 / Xcode 8 seems to truncate? Why?, I will also post my answer here, in case you want to use printf
instead.
This is a temporary solution,since I think it's a bug.
Just redefine all NSLOG
to printf
in a global header file.
#define NSLog(FORMAT, ...) printf("%s\n", [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
3
a Swift workaround for this new Xcode8 and Sierra “feature”…
func Log(_ format:String, _ args:CVarArg...) {
let output = withVaList(args, { (p) -> NSString in
NSString(format: format, arguments: p)
}) as String
print( output )
}
Of course, this won’t have the features of NSLog that we may require such as the time stamp, bundle name, and thread stuff (including serialization).

AutomatonTec
- 666
- 6
- 15