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
6
votes
3 answers

OCUnit, NSLog, and XCode 3.1

I'd been using OCUnit (the default installation that comes with XCode) in XCode 3.0. I've been happy being able to run my tests and see the results in the Build Results window, as well as any NSLog() messages I output. However, with XCode 3.1 the…
sehugg
  • 3,615
  • 5
  • 43
  • 60
6
votes
5 answers

How to get rid of the date and time that appears before every NSLog statement in the console

I use NSLog in my application. And I'd like to get rid of the annoying beginning of each string: "2009-07-01 21:11:06.508 MyApp[1191:207]". Is there a way to do so? Probably another logging function? Thanks.
Ilya Suzdalnitski
  • 52,598
  • 51
  • 134
  • 168
6
votes
1 answer

Why does string show up in NSDictionary with quotes, but others don't?

So I have an NSMutableDictionary that I populate, but when I output the contents to NSLog, the key and value for the entries entered in the for loop show up differently, and the final NSLog call doesn't even output anything. What's going on…
HackyStack
  • 4,887
  • 3
  • 22
  • 28
5
votes
2 answers

Looking for the cheapest way to use std::wstring with NSLog

I have a library which uses wstring extensively. I need to output changes and external data using NSLog Is there a simple way (not too expensive) to output the wstring using an intermediate function. Converting each wstring to NSString using va_list…
Coyote
  • 2,454
  • 26
  • 47
5
votes
2 answers

NSLog - Strange behavior

I found that last word showed with double quotes. But why? NSDictionary *guide2 = [NSDictionary dictionaryWithObjectsAndKeys:kArr, @"Kate", aArr, @"Ana-Lucia", kArr, @"John", nil]; NSArray *array = [guide2 allKeys]; NSLog(@"%@", [array…
Voloda2
  • 12,359
  • 18
  • 80
  • 130
5
votes
2 answers

NSLog() not outputting after callback

I've got an NSLog invocation in a method that I know is getting called (I've set a breakpoint). But there's not output in that method, or at all after that method. When the app starts up, my NSLog statements are working fine. I'm wondering if this…
marchaos
  • 3,316
  • 4
  • 26
  • 35
5
votes
8 answers

nslog stopped working in xcode

I have a strange issue and possibly a bug. My NSLog statements have stopped working completely, they do not print even in view did load, application didfinishlaunching etc. The have all turned a brown colour (the same colour as a pragma mark in…
Jules
  • 660
  • 8
  • 29
5
votes
1 answer

How to display system log on iPad/iPhone iOS device?

I want to be able to view all of the NSLog() messages from my App in the App itself. How do I access the system log of the device?
MikeN
  • 45,039
  • 49
  • 151
  • 227
5
votes
1 answer

A format specifier such as `%15@` works in NSLog but not with NSString stringWithFormat

I found something strange when trying to use width specifiers with %@. They work fine in NSLog but not with NSString stringWithFormat:. Example: NSString *rightAligned = @"foo"; NSString *leftAligned = @"1"; NSLog(@"| %15@ | %-15@ |", rightAligned,…
rmaddy
  • 314,917
  • 42
  • 532
  • 579
5
votes
3 answers

NSLog error: Can't find 'NXConstantString'?

I finally got GNUstep working (on windows), and it compiles and runs fine. However, whenever I try to use NSLog, I get the following error: $ gcc -o hello hello.m -I /GNUstep/System/Library/Headers \ > -L /GNUstep/System/Library/Libraries -lobjc…
John Howard
  • 61,037
  • 23
  • 50
  • 66
5
votes
1 answer

NSLog in submitted app

I had the misfortune of submitting an app with an NSLog still active. It very rarely fires, but I would like to know what are the chances of my app being rejected because of that? I am NOT asking how to supress NSLogs. I already know how to. It is…
John Smith
  • 12,491
  • 18
  • 65
  • 111
5
votes
3 answers

NSLog pointer syntax

I'm a little bit confused about the syntax of NSLog. For example, NSString *nameString = @"Name"; NSLog(@"nameString is: %@", nameString); If my understanding is correct (which it very well may not be), then nameString is defined…
Brett Johnson
  • 67
  • 1
  • 7
5
votes
1 answer

How to direct printf output to the same target as NSLog?

How can i make the output of printf appear in the Xcode Organizer console view? While debugging on a connected device i can see printf output right among NSLog output in th debug console in Xcode, but i can see only NSLog output on the Organizer…
Matti Jokipii
  • 561
  • 1
  • 6
  • 20
5
votes
1 answer

Hiding NSLog output coming from precompiled library

I am using a precompiled library I don't have the source of and it's printing a lot of debug logs. Is it possible to hide the output from just a specific library?
moinudin
  • 134,091
  • 45
  • 190
  • 216
5
votes
2 answers

iOS NSLog error with Unicode characters

Can anyone tell me the cause of the discrepancy for the following results ? completionHandler:^(NSArray *placemarks, NSError *error) { NSLog(@"\n placemarks%@",…
Μήτσος
  • 221
  • 2
  • 11