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.
I’m connecting from a Mac USB port via an FTDI cable using
screen as described in the FAQ.
Sorry, then I don’t know. Are you sure that your application is running? Do you see log messages from anything else?
I connected an HDMI display and I see the output as the RPi3 boots up, but no output from my application. The application is definitely running, because it responds to input from my remote transmitter and moves some motors correctly.
If you’re able to share your various
config/*.exs files (or maybe the whole project) so we can see how
Logger is configured, that would help. If you’re connected to the local
iex console (not a
--remsh session), you should see the
Logger logs, unless you have it configured to hide the
debug messages and those are the ones you’re expecting to see, for example.
I’ve seen this happen if
shoehorn (formerly known as
bootloader) fails to start an app. i suggest doing something along the lines of
application.ensure_all_started(:my_app) and checking for errors there.
shoehorn might be swallowing something
EDIT: sorry. Blindly responded. Didn’t see your conformation that you app is running.
WOW do I feel stupid. You are correct - it was configured to hide debug messages and I was using debug level logging everywhere. Thanks for the help!
Don’t feel bad. It’s almost always something silly like that, but it sometimes requires a second pair of eyes to question the basic assumptions.