7

In iOS10 the NSlog are limited to 1024 characters has anybody know a workaround to print complete string.

Naveen Shan
  • 9,192
  • 3
  • 29
  • 43
  • split string into 1024 char chunks and log each one individually. – Marc B Sep 16 '16 at 18:50
  • 1
    solution 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 Answers3

6

try printf then instead of NSLog like,

   printf("%s", [string UTF8String]);

It may works

Ketan Parmar
  • 27,092
  • 9
  • 50
  • 75
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]);
Community
  • 1
  • 1
xfdai
  • 2,735
  • 1
  • 19
  • 18
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