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

is there a popular open source NSLog replacement that handles enabling only in DEBUG and different log levels?

Is there a well known / popular NSLog replacement/approach that many iPhone developers are using? That is one that handles ensuring debug type logging only appears in debug states (macros etc), and support for different log levels (DEBUG, WARN,…
Greg
  • 34,042
  • 79
  • 253
  • 454
3
votes
2 answers

IOS/Xcode: Suppress NSLog Statements for Release in 2018

Because NSLog statements slow down apps, it seems advisable to remove them prior to release. A number of older answers on SO going back to 2010 suggest putting some code in the pch file such as: #ifndef DEBUG #define NSLog(...); #endif However,…
user6631314
  • 1,751
  • 1
  • 13
  • 44
3
votes
0 answers

Detect when building for archive

Is it possible to recognize when the build is made for archive? I have debug/release flags, and I want to print the app's logs at debug and hide them at release version. I can do that with #if debug...#else...#endif What I'm asking is, is it…
Witterquick
  • 6,048
  • 3
  • 26
  • 50
3
votes
1 answer

Did NSDate change it's description output?

When I log an NSDate to the console like this: NSDate *date = [NSDate date]; NSLog(@"date: %@", date); it logs the output: date: Fri Nov 17 09:35:27 2017 I was expecting the output to be more like this: date: 2017-11-17 09:35:27 +0000 For a…
nevan king
  • 112,709
  • 45
  • 203
  • 241
3
votes
1 answer

TRACE logging on iPhone

I am new to iPhone and trying to learn the sequence of methods invoked during application loading time. After some googling, I found this that seems to be adequate: NSLog(@"Begin %@ initWithNibName", [[self class]description]); But is there a…
jabawaba
  • 279
  • 1
  • 6
  • 16
3
votes
3 answers

how to see NSLog in my SDK project under iOS 10

I have a SDK project which will compile and build a framework. Inside this project, I have my person NSLog shown there. I have another framework test app to using this framework to do my task. After upgrading to iOS 10 and Xcode 8, I notice all the…
xiaoyaoworm
  • 1,052
  • 4
  • 13
  • 32
3
votes
2 answers

iOS 10 Logging framework: get recent logs at runtime

Until iOS 10, we could use the asl framework (Apple System Log) to access log messages written by NSLog at runtime. However, with iOS 10 Apple deprecated asl and replaced it with the new Logging framework. Is it still possible to load messages…
lukas
  • 2,300
  • 6
  • 28
  • 41
3
votes
1 answer

Why are NSLogs in Xcode 8 cut off?

I just installed Xcode 8 and I use NSLogs to see my server response and for other verifications.However, my NSLogs with my server response (in JSON) are getting cut off.Any Ideas?I am using objective-c and running my app on a real device.
Bryan Norden
  • 2,397
  • 18
  • 22
3
votes
1 answer

unable to log from inside of a pod framework

I have created a iOS & tvOS framework and i am using cocoapods to distribute it to all my projects. I am having difficulties when trying to do a NSLog from inside the classes of the framework. The framework is really simple, it is composed of…
YYfim
  • 1,402
  • 1
  • 9
  • 24
3
votes
2 answers

How to get "stringWithFormat" from NSLog() to Variable in Swift?

how to get the stringWithFormat from NSLog() in Swift? For example the Console Output is 2016-05-24 18:33:31.543 MyPlayground[15578:143357] This is a test!, so how to get the 2016-05-24 18:33:31.543 or 2016-05-24 18:33:31.543…
HelloToYou
  • 335
  • 5
  • 14
3
votes
2 answers

How to output values of a custom type using NSLog?

Background I'm using VES to leverage the Kiwi point cloud viewer on iOS devices. Error vesVector3f v = self->mKiwiApp->cameraFocalPoint(); NSLog(@"%@", v); results in Cannot pass non-POD object of type `vesVector3f` (aka 'Matrix') to…
Jacksonkr
  • 31,583
  • 39
  • 180
  • 284
3
votes
2 answers

How do i convert NSLog to string?

I have the following code, #define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); How do I convert NSLog output to a string so i can pass into log parameter? see below. #define DLog(fmt, ...) [MyClass…
PashaN
  • 444
  • 1
  • 4
  • 16
3
votes
4 answers

What does NSLog actually do?

I am having a weird problem. I am using a method from Apple's private frameworks in my application. When I call it for the first time, it works. When I call it for the second time immediately without anything in between, it crashes. However, if I…
ifvc
  • 31
  • 1
  • 3
3
votes
2 answers

NSLog crashes with certain NSURL- iOS 9.2

Here is my code,where the crash occurs:- let URL = NSURL(string: "http://files.parsetfss.com/fa80bc63-88d4-412d-a478-2451cffc92a9/tfss-1d2a321d-b02e-4745-a589-e31536f648df-XXXXX%20CAT15%2030.p0001.jpg") NSLog("Loading page with URL: \(URL)") The…
Vizllx
  • 9,135
  • 1
  • 41
  • 79
3
votes
1 answer

In Windows, is there an equivalent to syslog or OS X's Console.app for logging specific errors?

I'm writing a cross-platform application and am digging into a bit of its error handling. One of my approaches has been to display a message box to the user with a user-friendly error message when something sufficiently bad has gone wrong, while…
Bri Bri
  • 2,169
  • 3
  • 19
  • 44