可可环境中有哪些免费的、好的日志框架?
截至目前,我使用 NSLog 从我的 OS X 应用程序进行日志记录。但 NSLog 让我无法控制日志级别、日志文件的大小和数量。我在使用 NSLog 时面临的其他问题是,即使我将日志语句重定向到文件,我仍然会在系统日志中看到条目(使用控制台)。
我找到了一个日志框架 log4cocoa,但这看起来很旧。在做出决定并开始使用 log4cocoa 之前,我想知道哪些免费日志框架可用于 cocoa 以及它们的优缺点。
更新:我还发现了另一个名为 lumberjack 的日志记录框架。我要尝试这两个,看看它们如何公平
As of now I use NSLog for logging from my OS X application. But NSLog gives me no control over log level, size and number of log files. Other problem I face with NSLog is even though I redirect log statements to a file, I still see entries in System log (using console).
I found a logging framework log4cocoa, but this looks very old. Before making decision and start using log4cocoa, I want to know which all free logging frameworks are available for cocoa and merits / demerits of those.
Update: I also found one more logging framework called lumberjack. I am gonna try these two and see how they fair
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
OS X 包含一个内置的日志记录工具,即 Apple System Logger (ASL)。 ASL 支持多个输出流和日志记录级别。
Peter Hosey 的关于 ASL 的系列仍然是对 ASL 的最好介绍。系统及其API。 ASL API 是用 C 语言编写的,但编写 Objective-C 包装器和一些预处理器宏非常容易,以使您的生活更轻松。 Google Toolbox for Mac 具有
GTMLogger
支持平面文件、stdout 和 ASL 的类(通过 GTMLogger+ASL 类别)。如果您不介意使用额外的依赖项,我将使用 GTM 及其GTMLogger
工具。OS X includes a built-in logging facility, the Apple System Logger (ASL). ASL supports multiple output streams, and logging levels.
Peter Hosey's series on the ASL is still the best introduction to the system and its API. The ASL API is in C, but it's quite easy to write an Objective-C wrapper and some preprocessor macros to make your life easier. The Google Toolbox for Mac has the
GTMLogger
class that supports flat-file, stdout, and ASL (via the GTMLogger+ASL category). If you don't mind taking an additional dependency, I would use GTM and itsGTMLogger
facilities.也请检查 Best Logger for cocoa 答案。
Check Best Logger for cocoa answers too.