我可以在发布版本中保留日志记录吗?
我已阅读 这个问题提倡将 NSLog 语句从发布版本中取出。
是否可以接受,而不是用垃圾扰乱主日志,而是将其写入 Apple 系统日志,然后将其从主日志中隐藏?
或者我只是把事情复杂化了?在某些情况下,日志记录对于您在发布后查明应用程序中的错误很有用吗?
I've read this question which advocates taking NSLog statements out of Release builds.
Is it acceptable to, instead of cluttering the main log up with junk, write it to Apple System Log instead, then it'd be hidden from the main log?
Or am I just overcomplicating things? Are there any instances where logging has been useful to you in pinpointing a bug in an app after release?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我发现我在开发过程中添加的日志消息通常会执行以下三件事之一:
第一类消息 我通常在功能完成后删除 第二类消息我使用类似链接问题中的宏来过滤掉,以及我在版本中留下的第三类消息。
显然,界限是模糊的,但我认为这归根结底是尊重日志。如果您的应用程序充斥着无用的信息,则可能很难注意到其他应用程序的错误,并且会造成(小)资源消耗。
对于处于灰色区域的消息来说,使用 ASL 函数来记录大多数用户看不到的优先级较低的消息(例如
debug
和info
)是一个好主意。I find that log messages I add during development generally do one of three things:
Messages in category one I usually remove when the feature is complete, messages in category two I filter out with a macro like the one in the linked question, and messages in category three I leave in the release.
Obviously the lines are blurry, but I think it comes down to respecting the log. If your application floods it with information that isn't useful, it could make it difficult to notice errors from other applications, and will be a (small) resource drain.
Using ASL functions to log messages with lower priorities like
debug
andinfo
that won't be visible to most users is a great idea for messages that fall in a grey area.还有这个问题询问任何性能通过删除陈述来获得优势。陪审团似乎仍然没有确定任何硬性数字,但传统观点认为,可以通过以宏为条件包含它们来删除它们。您仍然可以获得调试信息,并且用户可以获得一个没有混乱的应用程序。
There is also this question that asks about any performance advantage by taking the statements out. The jury looks to still be out on any hard numbers, but conventional wisdom says to remove them by making their inclusion conditional with a macro. You still get your debugging info, and the user gets an app free of clutter.