Daniel Erat | ace8d362 | 2017-12-20 23:27:24 | [diff] [blame] | 1 | # Chrome Logging on Chrome OS |
| 2 | |
| 3 | ## Locations |
| 4 | |
| 5 | Messages written via the logging macros in [base/logging.h] end up in different |
| 6 | locations depending on Chrome's state: |
| 7 | |
François Degros | 0686ae99 | 2022-08-24 04:50:30 | [diff] [blame] | 8 | `/var/log/ui/ui.LATEST` |
| 9 | : contains data written to stdout and stderr by Chrome (and technically also |
| 10 | [session_manager]). This generally comprises messages that are written very |
| 11 | early in Chrome's startup process, before logging has been initialized. |
Daniel Erat | ace8d362 | 2017-12-20 23:27:24 | [diff] [blame] | 12 | |
François Degros | 0686ae99 | 2022-08-24 04:50:30 | [diff] [blame] | 13 | `/var/log/chrome/chrome` |
| 14 | : contains messages that are written before a user has logged in. It also |
| 15 | contains messages written after login on test images, where Chrome runs with |
| 16 | `--disable-logging-redirect`. |
| 17 | |
| 18 | `/home/chronos/user/log/chrome` |
| 19 | : contains messages that are written while a user is logged in on non-test |
| 20 | images. Note that this path is within the user's encrypted home directory |
| 21 | and is only accessible while the user is logged in. |
| 22 | |
| 23 | `/var/log/audit/audit.log`: |
| 24 | : contains SECCOMP violation messages. |
| 25 | |
| 26 | `/var/log/messages` |
| 27 | : contains messages written by services such as `session_manager`, |
| 28 | `cryptohomed` and `cros-disks` that may be useful in determining when or why |
| 29 | Chrome started or stopped. |
| 30 | |
| 31 | Some of the above files are actually symlinks. Older log files can be found |
Daniel Erat | ace8d362 | 2017-12-20 23:27:24 | [diff] [blame] | 32 | alongside them in the same directories. |
| 33 | |
François Degros | 0686ae99 | 2022-08-24 04:50:30 | [diff] [blame] | 34 | ## How to increase Chrome's log level to `INFO` on a test device |
Daniel Erat | ace8d362 | 2017-12-20 23:27:24 | [diff] [blame] | 35 | |
François Degros | 0686ae99 | 2022-08-24 04:50:30 | [diff] [blame] | 36 | By default, only `WARNING`, `ERROR` and `FATAL` messages are written to disk, |
| 37 | whereas `INFO` and `VERBOSE` messages are discarded. |
Daniel Erat | ace8d362 | 2017-12-20 23:27:24 | [diff] [blame] | 38 | |
François Degros | 0686ae99 | 2022-08-24 04:50:30 | [diff] [blame] | 39 | To log `INFO` messages, pass `--log-level=0` to Chrome. See the |
Daniel Erat | ace8d362 | 2017-12-20 23:27:24 | [diff] [blame] | 40 | [Passing Chrome flags from session_manager] document for more details, and |
François Degros | 0686ae99 | 2022-08-24 04:50:30 | [diff] [blame] | 41 | specifically the `/etc/chrome_dev.conf` configuration file that can be used to |
| 42 | change flags on test devices. |
| 43 | |
| 44 | Remount the root filesystem in read-write mode (to be able to modify |
| 45 | `chrome_dev.conf`): |
| 46 | |
| 47 | ```sh |
| 48 | (dut)$ sudo mount -o remount,rw / |
| 49 | ``` |
| 50 | |
| 51 | Add `--log-level=0` to `chrome_dev.conf`: |
| 52 | |
| 53 | ```sh |
| 54 | (dut)$ echo "--log-level=0" | sudo tee -a /etc/chrome_dev.conf > /dev/null |
| 55 | ``` |
| 56 | |
| 57 | Restart Chrome: |
| 58 | |
| 59 | ```sh |
| 60 | (dut)$ sudo restart ui |
| 61 | ``` |
| 62 | |
| 63 | Follow Chrome's logs: |
| 64 | |
| 65 | ```sh |
| 66 | (dut)$ tail -F /var/log/chrome/chrome |
| 67 | ``` |
Daniel Erat | ace8d362 | 2017-12-20 23:27:24 | [diff] [blame] | 68 | |
Ian Barkley-Yeung | 5e0d370 | 2019-01-04 19:10:39 | [diff] [blame] | 69 | ## Verbose Logging |
| 70 | |
François Degros | 0686ae99 | 2022-08-24 04:50:30 | [diff] [blame] | 71 | When actively debugging issues, Chrome's `--vmodule` flag can be used to log |
| 72 | verbose messages for particular modules. |
| 73 | |
| 74 | For example, to log `VERBOSE1` messages produced by `VLOG(1)` in |
| 75 | `volume_manager.cc` or `volume_manager.h`: |
| 76 | |
| 77 | ```sh |
| 78 | (dut)$ echo "--vmodule=volume_manager=1" | sudo tee -a /etc/chrome_dev.conf > /dev/null |
| 79 | ``` |
| 80 | |
| 81 | Restart Chrome: |
| 82 | |
| 83 | ```sh |
| 84 | (dut)$ sudo restart ui |
| 85 | ``` |
| 86 | |
| 87 | Follow `volume_manager`'s logs: |
| 88 | |
| 89 | ```sh |
| 90 | (dut)$ tail -F /var/log/chrome/chrome | grep volume_manager |
| 91 | ``` |
Ian Barkley-Yeung | 5e0d370 | 2019-01-04 19:10:39 | [diff] [blame] | 92 | |
Daniel Erat | ace8d362 | 2017-12-20 23:27:24 | [diff] [blame] | 93 | [base/logging.h]: ../base/logging.h |
John Palmer | 046f987 | 2021-05-24 01:24:56 | [diff] [blame] | 94 | [session_manager]: https://chromium.googlesource.com/chromiumos/platform2/+/main/login_manager/ |
| 95 | [Passing Chrome flags from session_manager]: https://chromium.googlesource.com/chromiumos/platform2/+/main/login_manager/docs/flags.md |