Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > NSLog & Log Files

NSLog & Log Files
Thread Tools
SSebeny
Junior Member
Join Date: Aug 1999
Location: Cuyahoga Falls, Ohio, USA
Status: Offline
Reply With Quote
Jun 30, 2005, 08:14 PM
 
Hi,

I've used NSLog in Cocoa to do basic "printf style debugging" while running the app from Xcode to see the log statements in the Xcode console. Then I normally remove all the NSLog statements when I'm done.

I recently observed that if I leave such NSLog statements in my Cocoa app that they end up in the system-wide console.log. Actually I guess I knew that, but it still surprised me when I saw them because I wasn't expecting it.

Anyway, down the road a bit I was thinking of making a crash reporter for my little app. And I thought it would be more convenient later if I make my app write its NSLogs to its own log file rather than the system-wide console.log. Thus I'm curious how I make my NSLog statements go to their own file rather than the standard system-wide console.log. Also, is it considered to be OK, correct, acceptable, or proper for an app to write to its own log file, or would that be considered improper, bad, etc for some reason? If so, why?

In looking up NSLog the docs say it calls NSLogv, and the docs for NSLogv say it writes the messages to STDERR_FILENO. So does that mean I'd just create my own file in ~/Library/Logs and open it and set the STDERR_FILENO file descriptor to it at launch? Is there anything else I should be aware of if I'm doing this?

Any advice, suggestions, etc are greatly appreciated. Thanks!
     
Ludovic Hirlimann
Mac Enthusiast
Join Date: Jul 2002
Location: Leiden, Netherlands
Status: Offline
Reply With Quote
Jul 7, 2005, 02:54 AM
 
Originally Posted by SSebeny
Hi,


Anyway, down the road a bit I was thinking of making a crash reporter for my little app. And

Any advice, suggestions, etc are greatly appreciated. Thanks!
Take a look at http://infinite-loop.dk/developer/
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 06:01 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,