Logging on the Freerunner

By default, the FreeRunner comes without a system log daemon, and rightfully so, because you don't want a daemon filling up /var, and a nightly cron job to rotate logs, on a mobile phone.

However, I do not want to give up logging. If there are bugs I want to investigate, I like to be able to look at the logs.

The solution: remote logging. Configure the phone to send all log info via UDP to my laptop, and configure my laptop to listen for UDP syslog messages from the phone only.

How to do it:

  1. apt-get install rsyslog (see below how other logging daemons fail)
  2. Add a /etc/hosts entry for the laptop on the phone: 192.168.0.200 base
  3. Add a /etc/hosts entry for the phone on the laptop: 192.168.0.202 openmoko
  4. Replace the phone's rsyslog rules to send everything to the laptop:

    ################
    ##### RULES ####
    ################
    
    # Everything goes to the main computer, via UDP, if available
    *.*     @base
    
    #
    # Emergencies are sent to everybody logged in.
    #
    *.emerg                         *
    
  5. Tell the laptop's rsyslog to accept UDP messages from the phone only:

    # provides UDP syslog reception
    $ModLoad imudp
    $UDPServerRun 514
    $UDPServerAddress 192.168.0.200
    

That is all. When the phone is not connected, the UDP packets from the logger will go nowhere. When it gets connected to the laptop, a script is triggered that creates the 192.168.0.200 interface, rsyslogd will listen on that interface and the UDP packets will be logged.

This has the extra potential to be able to get error messages in case of bugs in the SD card driver, which I seem to hit from time to time.

Why rsyslog

sysklogd could receive the messages from the phone, but can only listen on all interfaces, and therefore requires me to set up firewall on my laptop in order to get packets from the phone only.

syslog-ng can and can be told to listen on a given interface, but it will refuse to start if that interface isn't available. Since the phone is on an hotplugged interface that comes and goes, this is totally unacceptable.

And finally, rsyslog is going to replace sysklogd both in Debian and in Fedora, so it's just as well a good excuse to switch.