Ubuntu touch aprende a extraer logs

Today I’m going to tell you how to extract logs from your Ubuntu Device in order to report any bugs you find. When your device displays anomalous behaviour, have you ever wondered why that is? Logs are the answer to this question. They contain real-time information on how the system operates.

This article is directly related to Ubuntu Touch: how to report bugs in Launchpad, as in order to fully complete a bug report, in addition to all the usual information like the context of the bug, the firmware version, etc.,  logs provide the reason for the bug, which is a very important aspect.

What are logs?

I will first explain what a log is so you know exactly what I’m talking about, and why it is so important to extract this information from your Ubuntu device.

Logs are records of all system events. They are recorded in real time. They are a powerful tool to detect the precise moment at which the error took place, when the app or scope crashed, and so on.

The information they provide is used to study the context of the bug, the factors which influence it, and how to stop it happening again.

Ejemplo de eventos continuos en un syslog

Example of a syslog (system log)

What do you need to extract logs from your device?

Ubuntu Phone

You need to enable Developer mode in order to access the device via adb, which is the method you will use to connect and extract the logs. You can find this mode at the following location: System settings > About this device > Developer mode (you must then activate it).

You also need to have set some type of security code to lock the device.

Activate developer mode

Activate developer mode

En Ubuntu Desktop

You need a package with the necessary tools (drivers adb, normally) in order to launch extraction commands. In this case, BQ and Canonical recommend installing the following:

$ sudo add­-apt-­repository ppa:phablet-­team/tools
$ sudo apt­-get update
$ sudo apt-get install phablet-tools

Classifying the incident: What is the bug’s behaviour?

To know which logs you need in each case, I have listed the extraction paths below depending on the behaviour of the device. This will make it easier to remember and deal with.

  • If the bug restarted the device, what type of restart was it?
    • soft reboot: the session or app closes, and the Ubuntu Touch loading animation appears. In this case, select syslog, unity8 logs and crash logs.
    • hard reboot: the device reboots completely and the white BQ welcome screen appears when the device is switched on. Select last logs.
  • Did an app shut down or freeze suddenly?
    • Select the logs of the app in question.
    • Select crash logs.
  • Was the system directly affected?
    • Select syslog (this one is always essential).
  • Did it affect the graphical interface
    • Select unity8 logs.
  • Does it affect the Wi-Fi connection?
    • Enable special Wi-Fi logs for the syslog and reproduce the bug:
      $ sudo nmcli general logging level debug domains wifi,wifi_scan (enable logs)
      $ sudo nmcli general logging level info domains DEFAULT (disable logs)
  • Does it affect Bluetooth?
    • Select syslog.

Also enable special Bluetooth logs. Go to this page to see how.

Extraction routes

    • syslog: /var/log/syslog
    • unity8: /home/phablet/.cache/upstart/unity8.log


    • crash logs: /var/crash (in order for these logs to generate you need to activate Application crashes and errors at the following location: System settings > Security and privacy)
    • last logs: /var/log/lastlog


    • application log : /home/phablet/.cache/upstart/*

    Note: to verify the full route of the application which caused the bug, you can perform these steps:

    1. Connect your BQ mobile via USB with developer mode enabled.
    2. Open a terminal on a PC with Ubuntu and open an adb session with $ adb shell.

    Then list the content of the route: /home/phablet/.cache/upstart/. All of the full application paths will then appear:

Example of logs stored in the Upstart folder

Example of logs stored in the Upstart folder

  1. Copy the name of the app and add it to the end of the path. For example, if the gallery app crashed, the full path would be:

    $sudo adb pull /home/phablet/.cache/upstart/application-click-com.ubuntu.gallery_gallery_2.9.1.1260.log.1.gz

Every time you want to report a bug which is easy to reproduce, it is recommended that you delete previous logs relating to the bug in question. This will avoid confusing Canonical and make it easier for them to identify the bug.  To delete old logs, you can launch a command like the one below in a shell session with your Ubuntu PC or from the Terminal app:
$sudo rm <route where logs are stored>

Command to clean old logs

Command to clean old logs

Once deleted, you can reproduce the bug and then extract the logs. This will make the bug much easier to find (as the syslog logs events in chronological order) and the file will be much smaller when you upload it to Launchpad. If you include the time at which you reproduced the bug in the logs that you upload, you will make life much easier for Canonical.

Extracting logs

Once you have reproduced the bug, connect your USB to the computer to extract the files. The basic command to use is the following:
$sudo adb pull <extraction route> <destination route>

For example:
$sudo adb pull /var/log/syslog /home/”Your user”/Downloads

Extracting the files

Extracting the files

This procedure will allow you to fully complete a bug report, with a description of the error and all of the evidence confirming the bug’s existence. All of this makes bugs easier to resolve, and the solution can then be included in future OTA updates.

We hope that this article, together with Ubuntu Touch: how to report bugs in Launchpad, will help you correctly report bugs and thus aid the community to continually improve the Ubuntu Touch operating system.