ios iOS的日志框架?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3130614/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 17:23:43  来源:igfitidea点击:

Logging Framework for iOS?

ioslogging

提问by thndrkiss

Is there a logging framework for iOS that could aid developers in diagnosing app crashes?

是否有适用于 iOS 的日志记录框架可以帮助开发人员诊断应用程序崩溃?

回答by IlDan

You may like:

你可能喜欢:

"It is similar in concept to other popular logging frameworks such as log4j, yet is designed specifically for Objective-C, and takes advantage of features such as multi-threading, grand central dispatch (if available), lockless atomic operations, and the dynamic nature of the Objective-C runtime."

“它在概念上类似于 log4j 等其他流行的日志框架,但它是专门为 Objective-C 设计的,并利用了多线程、大中央调度(如果可用)、无锁原子操作和动态Objective-C 运行时的性质。”

"LibComponentLogging is a small logging library for Objective-C applications on Mac OS X and the iPhone OS which provides conditional logging based on log levels and log components. Additionally, different logging strategies can be used, e.g. writing log messages to a file or sending them to the system log, while using the same logging interface."

"LibComponentLogging 是一个用于 Mac OS X 和 iPhone OS 上的 Objective-C 应用程序的小型日志库,它提供基于日志级别和日志组件的条件日志记录。此外,可以使用不同的日志记录策略,例如将日志消息写入文件或发送将它们记录到系统日志中,同时使用相同的日志记录界面。”

  • NSLogger: fancy with a dedicated visualization OS X App
  • NSLogger: 喜欢一个专门的可视化 OS X 应用程序

"NSLogger is a high perfomance logging utility which displays traces emitted by client applications running on Mac OS X or iOS (iPhone OS). It replaces your usual NSLog()-based traces and provides powerful additions like display filtering, image and binary logging, traces buffering, timing information, etc."

"NSLogger 是一个高性能的日志实用程序,它显示运行在 Mac OS X 或 iOS (iPhone OS) 上的客户端应用程序发出的跟踪。它取代了您通常的基于 NSLog() 的跟踪,并提供了强大的附加功能,如显示过滤、图像和二进制日志记录,跟踪缓冲、时序信息等。”

回答by Victor P

I know this post is old but I'm looking for one as well. I found one called LumberHyman, though I haven't tried it yet.

我知道这篇文章很旧,但我也在寻找一个。我找到了一个叫LumberHyman 的,虽然我还没有尝试过。

回答by JAgostoni

I created a simple logging framework that might help. I'd appreciate any feedback you have. Hope it helps.

我创建了一个可能有帮助的简单日志框架。我很感激你的任何反馈。希望能帮助到你。

Link to Project Page

链接到项目页面

回答by Blake Ramsdell

This previous questionseems to overlap. But the bottom line is:

上一个问题似乎重叠。但底线是:

NSLog(@"message");

NSLog(@"message");

or:

或者:

printf("message");

printf("message");

回答by Kenneth Jiang

I have a slightly different need: not only do I want to debug crashes, but I also need to debug other errors (NSError, NSException).

我的需求略有不同:我不仅要调试崩溃,还需要调试其他错误(NSError、NSException)。

I tried all 3 packages mentioned in IlDan's answer. However, all of them require me to adopt a new way of logging, which may not be compatible with the libraries I depend on. For example, I intended to adopt NSLogger but RestKit, which is an important library in my project, uses LibComponentLogging.

我尝试了 IlDan 的回答中提到的所有 3 个软件包。但是,所有这些都要求我采用新的日志记录方式,这可能与我依赖的库不兼容。例如,我打算采用NSLogger,但我项目中的重要库RestKit 使用了LibComponentLogging。

So I ended up with writing a small pod (https://github.com/kennethjiang/Teleport-NSLog) for that. The mechanism is to redirect stderr (where NSLog + all these logging frameworks write messages to) to a backend HTTP server. Now I can debug my app running in user's device just as if it was running in my xcode. :)

所以我最终为此编写了一个小 pod ( https://github.com/kennethjiang/Teleport-NSLog)。该机制是将 stderr(NSLog + 所有这些日志框架将消息写入其中)重定向到后端 HTTP 服务器。现在我可以调试在用户设备中运行的应用程序,就像它在我的 xcode 中运行一样。:)

回答by Niklas Berglund

For basic logging use NSLog(@"your message here") If you want more flexible logging look into LumberHyman. It can let you disable logging in production etc etc.

对于基本日志记录,请使用 NSLog(@"your message here") 如果您想要更灵活的日志记录,请查看LumberHyman。它可以让您禁用登录生产等。