I am just getting started with Nerves. I managed to get it running on my Raspberry Pi3 and I can connect to it and access the GPIO pins from IEx. I have moved on to attempting to create an application that will run continuously while responding to input on GPIO pins. I’m am not seeing the response I expect, and I have no way to diagnose the problem. I can add logging to my input handlers to debug, but where can I see the output from the logging?
We’re happy to have you in the Nerves community!
On the rpi family (except the Zero), the console goes to the HDMI monitor output by default. If you hook up a monitor and keyboard, you should be able to use iex and see Logger output.
If you’d rather do it over the network, you can check out different Logger back-ends, like https://github.com/cellulose/logger_multicast_backend
You can also configure the console to be accessed using a USB-serial port on the UART pins on the GPIO header: https://hexdocs.pm/nerves/faq.html#using-a-usb-serial-console
Let me know if this is what you meant or if I misunderstood!
Ah, OK. I have it configured for the console to be accessed through the UART pins using screen from my Mac. I didn’t realize the logger output would show up in that console when it was coming from a separate process from IEx. Thanks!
Nerves doesn’t do anything special with regards to Logger handling, so if you have your
iex terminal configured to be on the UART pins, that will be your Group Leader, and the Logger output will go there by default using its
Just getting back to testing this. I find that I can execute logging statements like
iex and see the output printed, but any logging done from my running application does not show up anywhere.
remshing to the Raspberry Pi? That sounds like the default
:console Logger behavior. I.e., your application prints to what it thinks the console is (probably the HDMI output) and when you run
Logger.info manually at the remsh’d IEx prompt, it prints the message to your session.
The options are to hook up a monitor or use a different Logger backend. My preference is to use a different Logger backend so that you don’t have to worry about missing messages. In addition to the options that Greg mentioned, take a look at https://hex.pm/packages/ring_logger. It lets you get log messages printed over remsh or you can tail and “grep” its in-memory buffer.