FROM : Barry Wark
DATE : Wed Feb 27 22:43:31 2008
If you're using OS X 10.4 or later, you may want to check out the
Apple System Logger facility (a great series of posts on ASL start at
http://boredzo.org/blog/archives/2008-01-19/next-week-apple-system-logger).
It's not too hard to write your own Objective-C/#define wrapper around
ASL to get much more functionality than you can via NSLog (including
choosing where to direct logs, log message format, etc.)
barry
On Tue, Feb 26, 2008 at 4:58 AM, Martin <martin.<email_removed>> wrote:
> Le 26 févr. 08 à 11:53, Philip Bridson a écrit :
>
> > Is event logging really as easy as just declaring the location of
> > the application log directory and then passing the relevant event
> > string to NSLog which will "know" where to write the event?
>
> I'm not sure what you mean when you say "event logging" but the
> following code in my application's main.m redirects every NSLog output
> in "~/Library/Logs/MyApp.log":
>
> #ifndef DEBUG
> NSAutoreleasePool *pool = [NSAutoreleasePool new];
> NSString *logPath = [NSHomeDirectory()
> stringByAppendingPathComponent:@"Library/Logs/MyApp.log"];
> freopen([logPath fileSystemRepresentation], "a", stderr);
> [pool release];
> #endif
>
> The "#ifndef DEBUG" is there to disable the redirection when I'm in
> debug mode, so that the logs are actually displayed in XCode's console
> and not in the file.
>
> -Martin
>
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (<email_removed>)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>
>
DATE : Wed Feb 27 22:43:31 2008
If you're using OS X 10.4 or later, you may want to check out the
Apple System Logger facility (a great series of posts on ASL start at
http://boredzo.org/blog/archives/2008-01-19/next-week-apple-system-logger).
It's not too hard to write your own Objective-C/#define wrapper around
ASL to get much more functionality than you can via NSLog (including
choosing where to direct logs, log message format, etc.)
barry
On Tue, Feb 26, 2008 at 4:58 AM, Martin <martin.<email_removed>> wrote:
> Le 26 févr. 08 à 11:53, Philip Bridson a écrit :
>
> > Is event logging really as easy as just declaring the location of
> > the application log directory and then passing the relevant event
> > string to NSLog which will "know" where to write the event?
>
> I'm not sure what you mean when you say "event logging" but the
> following code in my application's main.m redirects every NSLog output
> in "~/Library/Logs/MyApp.log":
>
> #ifndef DEBUG
> NSAutoreleasePool *pool = [NSAutoreleasePool new];
> NSString *logPath = [NSHomeDirectory()
> stringByAppendingPathComponent:@"Library/Logs/MyApp.log"];
> freopen([logPath fileSystemRepresentation], "a", stderr);
> [pool release];
> #endif
>
> The "#ifndef DEBUG" is there to disable the redirection when I'm in
> debug mode, so that the logs are actually displayed in XCode's console
> and not in the file.
>
> -Martin
>
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (<email_removed>)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>
>
| Related mails | Author | Date |
|---|---|---|
| Philip Bridson | Feb 26, 11:53 | |
| Martin | Feb 26, 13:58 | |
| Philip Bridson | Feb 26, 14:31 | |
| Martin | Feb 26, 20:56 | |
| Tommy Nordgren | Feb 27, 02:40 | |
| Barry Wark | Feb 27, 22:43 |






Cocoa mail archive

