Objective-C记录最佳做法 [英] objective-c logging best practices

查看:78
本文介绍了Objective-C记录最佳做法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写第一个在后台工作的Objective-C守护程序类型的过程.它所做的一切都需要正确记录.

I am writing my first objective-c daemon type process that works in the background. Everything it does needs to be logged properly.

我对Apple知识还很陌生,所以我不确定,最常见和/或最好的记录活动的方法是什么?每个人都只是简单地以自己的特殊格式登录到文本文件,还是使用某种系统调用?

I am fairly new to Apple stuff so I am not sure, what is the most common and/or best way to log activity? Does everyone simply log to a text file in their own special format, or use some sort of system call?

推荐答案

您应该查看简介是我所知道的最好的. ASL是一种C级API,但是如果您愿意,可以将它包装在Objective-C中相对容易.我还建议您还看看 Google Mac版工具箱.在许多其他功能中,它包含GTMLogger工具,其中包括ASL支持.我放弃了自己的ASL包装程序,转而使用GTMLogger.

You should look at the Apple System Logger. ASL writes to the system log database (making it easy to query the log from Console.app or from within your own app) and additionally to one or more flat files (if you choose). Peter Hosey's introduction to the ASL is the best I'm aware of. ASL is a C-level API, but it's relatively easy to wrap in Objective-C if you'd like. I would recommend also taking a look at Google's Toolbox for Mac. Among many other goodies, it contains a GTMLogger facility that includes ASL support. I've ditched my home-grown ASL wrapper in favor of the GTMLogger.

这篇关于Objective-C记录最佳做法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆