ShaunVW
Posts: 37
Joined: Tue Aug 28, 2012 5:11 pm

Logging of application errors

Thu Nov 28, 2013 5:31 am

I have set up my Raspberry Pi connected serially to the Arduino to do some digital and analogue capturing (using Nanpy)
However, it randomly stops every few hours.
I have tried putting in some logging features to try figure out when/why it bombs out, but I'm not winning doing it this way.

I have it set up headless in a panel, and unfortunately I can't connect a screen to it to see what the reason is for it bombing out (well, I can, but it is mounted in a box, and I would have to unmount it to get my screen cable plugged in, and the environment is not the best)
I have read that errors are automatically logged into /var/log/errors.log. However, I don't seem to have that particular file on my Raspberry.
Is this the file I should be looking at? Will it give me the error message that would be displayed on the screen when the application bombs out? It is written in Python. I know the exact time that it stops working, so if I know where it is logged to, I can hopefully try find the cause of it.

Thank you for any advice.

User avatar
Davespice
Forum Moderator
Forum Moderator
Posts: 1662
Joined: Fri Oct 14, 2011 8:06 pm
Location: The Netherlands
Contact: Twitter

Re: Logging of application errors

Thu Nov 28, 2013 11:01 am

Hi there try this, it will give you the last 2000 lines of the syslog.

Code: Select all

tail -n 2000 /var/log/syslog

ShaunVW
Posts: 37
Joined: Tue Aug 28, 2012 5:11 pm

Re: Logging of application errors

Thu Nov 28, 2013 2:19 pm

Thanks, I came across that file, it didn't show me the info I was after.
However, what it did show is that I still had network connectivity after the program stopped, so I could safely say than loss of connectivity wasn't the cause.
Subsequently I came across a bug in my software which I've corrected, and I'm hoping it runs throughout the night :)
Any idea why I don't have that file though?

User avatar
Davespice
Forum Moderator
Forum Moderator
Posts: 1662
Joined: Fri Oct 14, 2011 8:06 pm
Location: The Netherlands
Contact: Twitter

Re: Logging of application errors

Thu Nov 28, 2013 3:19 pm

Which file?

ShaunVW
Posts: 37
Joined: Tue Aug 28, 2012 5:11 pm

Re: Logging of application errors

Fri Nov 29, 2013 8:00 am

errors.log under /var/log/

User avatar
DougieLawson
Posts: 35815
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Logging of application errors

Mon Dec 09, 2013 7:44 pm

I had to add my pi userid to group adm
sudo usermod -a -G adm pi
so I could read syslog

Then this python snippet (which I found with Google)

Code: Select all

import logging
import logging.handlers

my_logger = logging.getLogger('MyLogger')
my_logger.setLevel(logging.DEBUG)

handler = logging.handlers.SysLogHandler(address = '/dev/log')

my_logger.addHandler(handler)

my_logger.debug('this is debug')
my_logger.critical('this is critical')
wrote some nice pretty messages to /var/log/syslog
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

Return to “Troubleshooting”