-
-
Notifications
You must be signed in to change notification settings - Fork 341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Capture Logs from NSLog as Breadcrumbs #1247
Comments
Hey @fzyzcjy, which types of logs are you referring to? Would you please post some code snippets? Why do you want your logs as breadcrumbs anyway? |
@philipphofmann you know, swift's log, objc's log. e.g. these https://stackoverflow.com/questions/25951195/swift-print-vs-println-vs-nslog because logs provide precious clues when bugs comes! |
We currently don't support redirecting the output of NSLog, Swift's Logger, or |
@philipphofmann Thanks for the reply! However, I see some third party libs use NSLog to print out things. Then how can I capture them? |
Sorry for the late reply. Why do you want to capture third-party logs, @fzyzcjy? Just to understand your use case. |
@philipphofmann b/c I use some third-party libs. Some of them only output logs to NSLog or something like that. And you know, in production environment, it is critical to capture logs, such that we can have more information when bug happens |
I am not pretty sure how to achieve this, since I am not an expert in ios (but mostly doing flutter things). Your suggestions seem promising! |
I'm very interested in this feature for the extra clues that might be in logs. As of iOS 15, an app can get its own logs:
It seems to be a common convention to specify
|
Also I see |
We might be able to stream the logs from the OSLogStore, see https://steipete.com/posts/logging-in-swift/#update-ios-15 and https://github.com/steipete/OSLogTest. |
FYI, I've been investigating this as well. I started by experimenting with the following snippet to send OSLog entries to Sentry: The caveat is that the OSLogStore is very slow, so we only get a batch of logs every 10-15 seconds, which means that you'll likely miss the logs leading up to a crash. A better approach could be to attach the logs from the last hour as breadcrumbs with every Sentry event using the While the latter option works well for messages, it unfortunately does not work for crashes since they are sent the next time the application starts. In that case, we only get the logs from the |
Thank you, @garriguv, for the update. 👏
Are these up to date or also 15 seconds delayed?
Do you mean logs from the last app launch that crashed? Wouldn't that be enough? |
I meant the logs from the latest app launch, the one after the crash happened, which is not enough. I updated my post to clarify that point.
I actually don't know. I think that building a little test bench project is the correct next step here. Maybe a good idea for your upcoming Hacktoberfest? 😉 |
Hacktoberfest is actually for contributing to open source. I added the tag because I thought it might be something a contributor could have a shot at. Thanks for the update, @garriguv. |
Reading the application logs that led up to a crash is something I also have been missing a lot with Sentry. It's a feature I'm used to from Firebase/Crashlytics and Bugsnag. Breadcrumbs intend to solve the same problem but they only capture a small fraction of the information developers typically print to the console. We already have a custom "report a bug" feature in our app which attaches the logs. My initial thought was that I could just attach these logs to a Sentry crash. Here is how we did that with Bugsnag, there is a closure you pass in when initializing Bugsnag which allows you to attach information to a crash when it happens. Unfortunately it doesn't look like this is possible in Sentry, as the docs state "Please note that attachments don't work yet with crashes.". |
@mplorentz, adding info to a crash while it happens will be possible with #3408, but I can't give you an ETA. You could try adding your logs, if they aren't too big, to the context which also ends up in crash events with something like SentrySDK.configureScope { scope in
scope.setContext(value: [
"log 1": "login",
"log 2" : "log out",
], key: "my_logs")
} |
Thanks @philipphofmann. I subscribed to #3408. Our logs are pretty big right now so I'm not going to attempt the |
@mplorentz, another idea is that you could use initialScope to add attachments and then remove them sometime later after initializing the SDK. |
Environment
How do you use Sentry?
Sentry SaaS (sentry.io) or self-hosted/on-premise (which version?)
saas
Which SDK and version?
e.g: JavaScript 5.11.1, .NET 1.2.0
ios
Steps to Reproduce
use sample
Expected Result
want to automatically capture logs to sentry breadcrumb
Actual Result
Cannot automatically capture logs to sentry breadcrumb
thanks!
The text was updated successfully, but these errors were encountered: