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
3
votes
1 answer

iphone NSLog when displaying an array

First when I am using nslog to log the contents of an array, why is it that some of the objects in the array (all strings) have quotation marks around them and some dont? The log will look like: "Item 1", "item 2", item3, "item4" This leads to my…
Brodie
  • 3,526
  • 8
  • 42
  • 61
3
votes
1 answer

How to NSLog an Optional Int in Swift?

NSLog is still around in Swift, and offers some extras not available with println such as the timestamp, module, and thread. However, I'm unsure how to log an optional, for example an optional Int. Logging an unwrapped optional works fine, e.g. if…
Max MacLeod
  • 26,115
  • 13
  • 104
  • 132
3
votes
2 answers

iphone nsarray problem?

Okay maybe i just need another set of eyes on this, but I have the following lines of code in one of my view controllers. It takes some data from a file, and populates it into an array using "\n" as a separator. I then use that array to make an…
Brodie
  • 3,526
  • 8
  • 42
  • 61
3
votes
4 answers

Is leaving NSLogs on a security risk?

Let's say you have a app which uses passwords. During development, you want to troubleshoot some things, and use NSLog() to print out the password to see if it is working properly. At a certain moment you are happy and everything is working. You…
user3892683
3
votes
2 answers

Xcode find/search text in output log

I'm working with massive logs when my app is running, and i was just wondering if there was a way to search for specific text in the output log (where your NSLogs and such appears). I have about 1000 lines and even when i know the whereabouts of…
Gil Sand
  • 5,802
  • 5
  • 36
  • 78
3
votes
1 answer

KeyboardViewController NSLog IOS 8

We can log with NSlog in other view in iOS 8 (Xcode Beta Version). However, I can't NSLog in keyboard extension in KeyboardViewController. It didn't appear in log. NSLog(@"viewdidload in keyboard"); I would like to know how to detect/log in real…
Khant Thu Linn
  • 5,905
  • 7
  • 52
  • 120
3
votes
1 answer

NSLog crashing app using 3.1.3 software

the other day I had a bug submitted for my app from a user on an ipod touch with 3.1.3 software. It was a strange bug as no-one else has submitted it yet. Long story short, it appears that anywhere where I have NSLog() in code it will actually…
Matt Facer
  • 3,103
  • 11
  • 49
  • 91
3
votes
1 answer

NSLog() vs printf() when printing C string (UTF-8)

I have noticed that if I try to print the byte array containing the representation of a string in UTF-8, using the format specifier "%s", printf() gets it right but NSLog() gets it garbled (i.e., each byte printed as-is, so for example "¥" gets…
Nicolas Miari
  • 16,006
  • 8
  • 81
  • 189
3
votes
3 answers

What does "autoresize = W+H;" mean in NSLog output of a UIView object

Code: NSLog(@"[self view] = %@", [self view]); Output: [self view] = > I tried to [[self view] setFrame:CGRectMake(0, 64, 320, 568 +…
George
  • 3,384
  • 5
  • 40
  • 64
3
votes
1 answer

iPhone - NSLog does not print when app is in background

One of my VoIP enabled app prints log for every 5 mins interval when app is in background. But this log did not show at the time of log time. All log shows at the moment of application coming to foreground by pressing on it. But why? Any help…
MD SHAHIDUL ISLAM
  • 14,325
  • 6
  • 82
  • 89
3
votes
2 answers

Objective-C: Determine which file has performed an NSLog

Say I have 10 different implementation files that are run in an chaotic order, and in each of them I have an NSLog(@"Log");, and when I run the program I will get 10 Log's to my console output, but how can I know which one was logged by which file?…
nemesis
  • 1,349
  • 1
  • 15
  • 30
3
votes
2 answers

(iOS) Way of viewing log messages directly on an iOS device?

As nice as debuggers have gotten these days, sometimes the best way of finding out what is going on in an app is still ye olde NSLog. Doing this is easy when you're tethered to your computer; Xcode helpfully pops up the Log Viewer panel and there…
Donald Burr
  • 2,281
  • 2
  • 23
  • 31
3
votes
2 answers

NSLog suppress date

I find NSLog() statements really hard to read because of the verbose date. Is there a way to suppress the date on NSLog?
bobobobo
  • 64,917
  • 62
  • 258
  • 363
3
votes
2 answers

how to put NSString in NSLog with multiple arguments

when i try to use NSLog like: NSLog(@"one" @"two" @"three"); this works and prints onetwothree in console. but when i try to use like this NSString *s = [NSString stringWithFormat:@"three"]; NSLog(@"one" @"two" s); the above doesnt work and i…
g.revolution
  • 11,962
  • 23
  • 81
  • 107
3
votes
3 answers

NSLog inside variable arguments function

I do not have clear idea about objective c variable argument function. I want to write a function which will take a nlsog type parameter but sometime I shall use NSLog inside that function. How can I do that? -(void) printStatus:(NSString*)status,…
karim
  • 15,408
  • 7
  • 58
  • 96