Retired Document
Important: This document may not represent best practices for current development. Links to downloads and other resources may no longer be valid.
Logging Messages
You use the NSLog
and NSLogv
functions to log error and informational messages. These messages are written to stderr
.
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 these functions is that which is understood by NSString’s formatting capabilities (which is not necessarily the set of format escapes and flags understood by printf
). For example, the following code fragment, outputs a string constructed from NSString and int
arguments.
int recNum; |
NSString *recName; |
/* ... */ |
NSLog( @"Record %d is %@", recNum, recName ); |
See Formatting String Objects for a description of the various format specifiers.
In general, you should use the NSLog
function instead of calling NSLogv
directly. If you do call NSLogv
directly, you must have prepared the required variable argument list by calling the standard C macro va_start
. Upon completion, you must similarly call the standard C macro va_end
for this list.
Copyright © 2006 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2006-04-04