Questions tagged [nslog]

Logs an error message to the Apple System Log facility.

The message consists of a timestamp and the process ID prefixed to the string you pass in. You compose this string with a format string and one or more arguments to be inserted into the string. The format specification allowed by this function is that which is understood by NSString’s formatting capabilities.

Displaying log messages in the system console while running your application is one of the oldest debugging mechanisms available. Using logging, you can generate a transcript describing the operations being performed by your application that you can review long after your application has finished running. Also, while your application is running, you can observe log messages being generated and written to the console as the events in your app they describe are taking place. As a developer, you are in complete control of the text and information displayed in the console by NSLog. Logging can reveal even the toughest to find problems in an app.

Here is an example of what a call to NSLog looks like:

NSString *message = @"test message";

NSLog( @"Here is a test message: '%@'", message );

Console:

Here is a test message: 'test message'

Reference:

Basic debugging with the NSLog function and the DEBUG preprocessor macro

667 questions
11
votes
1 answer

How to invoke method with CVaListPointer parameters in Swift

How should I invoke the following method? The method belongs to a class that prints logs. func log(format: String!, withParameters valist: CVaListPointer) What I want to achieve, would look like this in Objective-C: NSLog(@"Message %@ - %@",…
mikywan
  • 1,495
  • 1
  • 19
  • 38
11
votes
2 answers

Why does NSLog sometimes print out octal for ucode characters?

I'm running the following code in the viewDidLoad function of a vanilla iPad single view app: /* * Print the string. A lot. */ for (int i = 0; i < 300; i++) { NSLog(@"%d\n", i); NSLog(@"⊢ ⊣ ⊥ ⊻ ⊼ ⊂ ⊃ ⊑ ⊒ \n"); } The output looks like…
Tim Kolar
  • 175
  • 1
  • 9
11
votes
1 answer

Is there any way to clear NSLog Output?

I have been googling from last couple of hours for finding that is there any way to clear NSLog output using code or not? Like we have clrscr() in c. So if we are trying to print something which we want to focus most and there is lots of log printin…
Kapil Choubisa
  • 5,152
  • 9
  • 65
  • 100
10
votes
0 answers

NSLog sending messages to system.log in macOS Sierra

After updating to macOS Sierra my fairly old and previously ok application has stopped sending NSLog messages directly to Console. Instead I have to view the messages in system.log. Is this expected behaviour, or is there some migration I need to…
Tim
  • 4,560
  • 2
  • 40
  • 64
10
votes
4 answers

Removing Logs when releasing iOS app

Currently I am building two apps for my project one in release & another in debug (the only thing that changes are provisioning profiles used to sign and the endpoints) . Because of some policies, I shouldn't be creating ipa files locally. So I use…
Rui Peres
  • 25,741
  • 9
  • 87
  • 137
10
votes
3 answers

Generating a String from CLLocationDegrees, e.g. in NSLog or StringWithFormat

Hello Stacked-Experts! My question: How to generate a string from a CLLocationDegrees value? Failed attempts: 1. NSLog(@"Value: %f", currentLocation.coordinate.latitude); //Tried with all NSLog specifiers. 2. NSNumber *tmp = [[NSNumber alloc]…
ABeanSits
  • 1,725
  • 1
  • 17
  • 34
9
votes
6 answers

is NSLog() stored on the device (iPhone etc)? If so, where?

Should all NSLog() calls be deleted in the final app for iTunes? In my iOS app, I've got lots of NSLog() for debug. Should I conditionally code them out before uploading to iTunes? This is for an app for: iPhone, iPod, iPad Thanks.
Doug Null
  • 7,989
  • 15
  • 69
  • 148
8
votes
1 answer

How to disable logging?

I have an app that is making use of UITextChecker class provided by Apple. This class has a following bug: If the iOS device is offline (expected to be often for my app) each time I call some of UITextCheckers methods it logs following to…
Rasto
  • 17,204
  • 47
  • 154
  • 245
8
votes
3 answers

NSLog without new line

Is there any function that does what NSLog does but without the new line at the end?
philip
  • 81
  • 1
  • 2
8
votes
2 answers

iPhone: Once I have redirected NSLog to a file, how do I revert it to the console?

I'm using: #if TARGET_IPHONE_SIMULATOR == 0 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *logPath = [documentsDirectory…
Ben Clayton
  • 80,996
  • 26
  • 120
  • 129
8
votes
7 answers

How to view logs from iPhone?

I have place several NSLog() in my iOS application, is it possible to see all the logs later on my Mac that was generated when the app ran on iPhone handset even when iPhone was not connected with Mac. Thanks
Firdous
  • 4,624
  • 13
  • 41
  • 80
7
votes
3 answers

Objective-C: Create text file on device and easily retrieve the file

I am wanting to write my own logs to a text file on my iPhone. I wrote up a quick method that writes a string to a file. Right now it saves it into the Documents directory, which, if on the device is going to be a pain to get off, since I can't just…
Nic Hubbard
  • 41,587
  • 63
  • 251
  • 412
7
votes
5 answers

NSLog on the device, is that a problem or must i remove that?

I have read this post: what happens to NSLog info when running on a device? ...but wondering if NSLog is a problem when distributing the app such as filling up the memory or something? I am only interested to see it when i test the consistency of my…
PeterK
  • 4,243
  • 4
  • 44
  • 74
7
votes
3 answers

Difference between NSLog and NSLogv

Can anyone explain the difference between NSLog and NSLogv? I know NSLog is used to print data in the console. But what is NSLogv?
Human
  • 326
  • 2
  • 3
  • 15
7
votes
7 answers

Is it ok to submit the iPhone app binary with NSLog statements?

I am just about to submit my first iPhone app. I have put lots of NSLog statements to test and debug the application . So my question is " Is it ok to keep the NSLog statements in the source code " and I have a doubt that whether the nslog…
harshalb
  • 6,012
  • 13
  • 56
  • 92