| 1 |
--- |
| 2 |
title: Logging |
| 3 |
description: Enable logging to inspect events while building your project. |
| 4 |
categories: [] |
| 5 |
keywords: [] |
| 6 |
--- |
| 7 |
|
| 8 |
## Command line |
| 9 |
|
| 10 |
Enable console logging with the `--logLevel` command line flag. |
| 11 |
|
| 12 |
Hugo has four logging levels: |
| 13 |
|
| 14 |
`error` |
| 15 |
: Display error messages only. |
| 16 |
|
| 17 |
```sh |
| 18 |
hugo build --logLevel error |
| 19 |
``` |
| 20 |
|
| 21 |
`warn` |
| 22 |
: Display warning and error messages. |
| 23 |
|
| 24 |
```sh |
| 25 |
hugo build --logLevel warn |
| 26 |
``` |
| 27 |
|
| 28 |
`info` |
| 29 |
: Display information, warning, and error messages. |
| 30 |
|
| 31 |
```sh |
| 32 |
hugo build --logLevel info |
| 33 |
``` |
| 34 |
|
| 35 |
`debug` |
| 36 |
: Display debug, information, warning, and error messages. |
| 37 |
|
| 38 |
```sh |
| 39 |
hugo build --logLevel debug |
| 40 |
``` |
| 41 |
|
| 42 |
> [!NOTE] |
| 43 |
> If you do not specify a logging level with the `--logLevel` flag, warnings and errors are always displayed. |
| 44 |
|
| 45 |
## Template functions |
| 46 |
|
| 47 |
You can also use template functions to print warnings or errors to the console. These functions are typically used to report data validation errors, missing files, etc. |
| 48 |
|
| 49 |
{{% render-list-of-pages-in-section path=/functions/fmt filter=functions_fmt_logging filterType=include %}} |
| 50 |
|
| 51 |
## LiveReload |
| 52 |
|
| 53 |
To log Hugo's LiveReload requests in your browser, add this query string to the URL when running Hugo's development server: |
| 54 |
|
| 55 |
```text |
| 56 |
debug=LR-verbose |
| 57 |
``` |
| 58 |
|
| 59 |
For example: |
| 60 |
|
| 61 |
```text |
| 62 |
http://localhost:1313/?debug=LR-verbose |
| 63 |
``` |
| 64 |
|
| 65 |
Then monitor the reload requests in your browser's dev tools console. Make sure the dev tools "preserve log" option is enabled. |