What will happen to NSLog claims in production?

When we submit an application with NSLog operators,

What will be the effect of the statements? Will they still be executed? If it will be executed, will these logs be stored somewhere in the form of application logs / system logs? Can we see them? Is this related to Apple crash report in iTunesConnect?

Please clarify my doubts.

+7
ios objective-c iphone ipad
source share
5 answers

Short answer: -

  • Yes, it runs in a working application
  • NSLog just logs in to the console, I don’t think it is stored somewhere.
  • We can only see on the console.
  • When the application crashes, NSLog does not print crash reports.
+7
source share

NSLog calls can be left in production code. It will be recorded in the system log. Applications that clog the syslog are annoying and unprofessional. So try using macros in Logging so that you can remove the execution of the log code during production

 #define DEBUG_MODE #ifdef DEBUG_MODE #define DebugLog( s, ... ) NSLog( @"<%p %@:(%d)> %@", self, [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] ) #else #define DebugLog( s, ... ) #endif 
+5
source share

NSLog reports will remain in production. You can find them in your xCode-> windows-> Organizer (shift + cmd + 2) if you connected your device. Check out the Console, which you can see, as well as other people who use the application.

enter image description here

+4
source share

Yes, the statement is executed if you left it in the release build.

So, it’s better to understand the NSLog comment in the release build or use DEBUG MODE as @Lithu TV said

By doing this, performance will get better. Because NSLog is pretty slow. NSLog will do two things: 1) write log messages to the system log (ASL) 2) if the application runs in xcode, it is also written to stderr.

The main problem lies in the first. To ensure thread safety, each time an NSLog is called, it opens a connection to an ASL object, sends a message, and closes the connection. The connection operation is very expensive. Another reason is that NSLog spends some time to get a timestamp for registration.

UPDATE: Also, I don’t think there is a direct way to check the log from the system, however there are some software tools that help to view the console log. The following might help you in displaying the console log: http://support.apple.com/kb/DL1465

I have never tried this myself. So I can’t give you a guarantee.

+2
source share

NSLog statements will be stored and executed in production if you are not going to delete them. This is not a good practice. If it affects the performance of the application.

There is a good tutorial on displaying magazines on MobileTuts +

Tuts Plus NSlog Mobile Tutorial

In any case, if you want to save it, you need to save it somewhere in the document directory, but then you also cannot get files from the device’s application directory. To do this, you can upload it somewhere in the webserver or something like that. Then you can access them.

Please let me know if you still have doubts.

+2
source share

All Articles