question

KiranPradeep-3782 avatar image
0 Votes"
KiranPradeep-3782 asked asergaz commented

Azure Sphere logging

For Sphere devices, we can vscode/cli to deploy, debug and see logs of the application \[1\]. But later (say I kept it running for 24 hours and comes back), if I wish to see application logs, it looks like, I don't have a way. Is there a way to see application logs on Sphere development boards without initiating the debugger?

To be clear, this is not about monitoring applications deployed in production \[2\]. This is only about development logs on Azure Sphere development boards. An example is logcat in Android \[3\]. The intention is to analyse long running application on Azure Sphere. We cannot keep the debugger attached forever.


azure-sphere
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

asergaz avatar image
2 Votes"
asergaz answered asergaz commented

Hello @KiranPradeep-3782 ,
Please check the article on Best Practices for high-level applications - Error handling and logging

For your case, where you want to analyse long running application on Azure Sphere without attaching the debugger the best and recommended approach is to send the value of the errno variable through D2C messages to an IoT Hub.


===UPDATE====

Alternatively you can capture/redirect the output stream to a file:
https://docs.microsoft.com/en-us/azure-sphere/app-development/manual-build#debug-the-application


36875-image.png



You don’t actually need to use gdb/debugger to access this output stream from a connected device. A terminal client reading that stream can save/redirect their output to file.


Remember:
- Please accept an answer if correct. Original posters help the community find answers faster by identifying the correct answer. Here is how.
- Want a reminder to come back and check responses? Here is how to subscribe to a notification.




· 10
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Again to confirm, I am not asking for logs of applications running in Production device group. This is only for development testing (device groups: Development/FieldTesting). But even during development testing, I cannot attach debugger for say 72 hours (+ that would result in non production performance). Does the answer remain same? If yes, I will be hugely disappointed. I cannot imagine streaming all logs to IoT Hub as D2C messages!

I like to see how my application behaved over time. Errno is just not sufficient.

0 Votes 0 ·
asergaz avatar image asergaz KiranPradeep-3782 ·

Hi @KiranPradeep-3782 ,
I have talked with the team and confirmed that you can capture/redirect the output stream to a file:

36875-image.png



You don’t actually need to use gdb/debugger to access this output stream from a connected device. A terminal client reading that stream can save/redirect their output to file .

I will update the answer with this info if you accept it.

Thanks


1 Vote 1 ·
image.png (304.3 KiB)

Thanks for the answer and the effort. I will try this out later. But I feel that will work. Humbly requesting you to update the answer and I will accept the same.

1 Vote 1 ·
Show more comments

Hello @KiranPradeep-3782 please let us know if you have further questions or you can accept the answer?

Thank you!

0 Votes 0 ·