Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What will happen to NSLog statements in production?

When we submit the application with NSLog statements,

What will be the effect of the statements? Will those still executes? If it executes will these logs stored somewhere as application logs / system logs? Can we see those? Is it connected to Apple crash reporting in iTunesConnect?

Please clarify my doubts.

like image 626
Easwaramoorthy K Avatar asked Nov 11 '13 11:11

Easwaramoorthy K


People also ask

Where does NSLog go?

As such, you can rely on it being available for your debugging purposes on any Apple platform where your app will run. NSLog outputs messages to the Apple System Log facility or to the Console app (usually prefixed with the time and the process id).

Is NSLog thread safe?

In the Thread Programming Guide, NSLog() is listed as being 'generally considered to be thread-safe'.


2 Answers

Short answer :-

  1. Yes it executes in the production app
  2. NSLog just log to the console, i do not think it is stored in somewhere.
  3. We can only see in the console.
  4. When application crash NSLog does not print in the crash submission reports.
like image 117
Hussain Shabbir Avatar answered Sep 29 '22 14:09

Hussain Shabbir


NSLog calls can be left in production code. It will be logged in the system log. Applications which litter the system log are annoying, and is an unprofessional way. So try to use Macros in Logging such that you can remove log code execution in 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
like image 24
Lithu T.V Avatar answered Sep 29 '22 15:09

Lithu T.V