# Logging (/debugging/log)



LVGL has a built-in *Logging* module to inform the user about what is
happening in the library.

Configuring Logging [#configuring-logging]

Log Level [#log-level]

To enable logging, set <ApiLink name="LV_USE_LOG" /> in `lv_conf.h` to a non-zero value and
set <ApiLink name="LV_LOG_LEVEL" /> to one of the following values.  They are prioritized as
follows (from most to least verbose):

* <ApiLink name="LV_LOG_LEVEL_TRACE" />: A lot of logs to give detailed information
* <ApiLink name="LV_LOG_LEVEL_INFO" />: Log important events.
* <ApiLink name="LV_LOG_LEVEL_WARN" />: Log if something unwanted happened but didn't cause a problem.
* <ApiLink name="LV_LOG_LEVEL_ERROR" />: Log only critical issues, where the system may fail.
* <ApiLink name="LV_LOG_LEVEL_USER" />: Log only custom log messages added by the user.
* <ApiLink name="LV_LOG_LEVEL_NONE" />: Do not log anything.

When you set <ApiLink name="LV_LOG_LEVEL" /> to a certain level, only messages with that level
or higher priority (less verbose) will be logged.

Example:  you set <ApiLink name="LV_LOG_LEVEL" /> to <ApiLink name="LV_LOG_LEVEL_WARN" />, then
<ApiLink name="LV_LOG_LEVEL_WARN" />, <ApiLink name="LV_LOG_LEVEL_ERROR" /> and
<ApiLink name="LV_LOG_LEVEL_USER" /> messages will be logged.

Log Output [#log-output]

If your system supports `printf`, you just need to enable
<ApiLink name="LV_LOG_PRINTF" /> in `lv_conf.h` to output log messages with `printf`.

If you can't use `printf` or want to use a custom function to log, you
can register a "logging" function with <ApiLink name="lv_log_register_print_cb" />.

For example:

```c title=" " lineNumbers=1
void my_log_cb(lv_log_level_t level, const char * buf)
{
  serial_send(buf, strlen(buf));
}

...


lv_log_register_print_cb(my_log_cb);
```

Using Logging [#using-logging]

You use the log module via the following macros:

* <ApiLink name="LV_LOG_TRACE" />(text)
* <ApiLink name="LV_LOG_INFO" />(text)
* <ApiLink name="LV_LOG_WARN" />(text)
* <ApiLink name="LV_LOG_ERROR" />(text)
* <ApiLink name="LV_LOG_USER" />(text)
* <ApiLink name="LV_LOG" />(text)

The first 5 macros append the following information to your `text`:

* Log Level name ("Trace", "Info", "Warn", "Error", "User")
* `__FILE__`
* `__LINE__`
* `__func__`

<ApiLink name="LV_LOG" />(text) is similar to <ApiLink name="LV_LOG_USER" /> but has no extra information added.

API [#api]
