How to Use Odoo 17’s Logging Features

June 27, 2024

Using logging techniques, we may examine the actions that occur within the Odoo server when it is being used. The logs will reveal any faults or warnings, and by doing so, we will be able to identify more effective ways to address them. Different degrees of logging are used to examine server processes. The use of logging in Odoo 17 will be covered in this blog.


To begin, import the Python logging module: import logging, for example. * Then, make a logger instance for the odoo class: _logger = logging.getLogger( name ) *, for example.Next, log the messages using, _logger.warning(), or _logger.error().

Including logging preferences in the odoo—conf Odoo configuration file is also possible. As an illustration, Choose the log level (critical, error, warning, info, or debug).log_level = information

Configure the log file’s path.

/path/log/file.log is the logfile.

The path indicated here is the actual path where the log file will be kept. To classify the log messages, there are many log levels. Assemble the handler for a specific PREFIX at a LEVEL. log_handler = TABLE: TABLE

  1. DEBUG

It’s primarily used to troubleshoot or confirm that operations are moving forward.


Should an unforeseen problem arise in the future, utilise this log level to ensure that the same procedures are carried out.

  • Mistake

It won’t carry out any more tasks if a problem arises.


Indicate the inability to carry out the programme and maintain operations if a serious problem arises.

Let’s examine an illustration using these various log levels.

* To begin, import the logging module and set the logger’s initial value to a variable.

import logging
_logger = logging.getLogger( name )

*Next, develop any function to display the various log levels. That is,

class ProductPriceList(models.Model):

_inherit = "product.pricelist" @api.on change('currency_id') def onchange_currency_id(self):

""" Logging at different levels """

_logger.debug("------------IT IS DEBUG--------------------- ")"-------------IT IS INFO----------------------- ")

_logger.error("------------IT IS Error--------------------- ")

_logger.warning("----------IT IS warning------------------ ")

_logger.critical("----------IT IS Critical------------------ ")

Here, I constructed an on-change function to log at several levels. When we run this function, we can look at the log. ie,

Here we may see the log at the desired levels. If we define a log level, only that level and higher will be logged. So, if we want to include debug messages in the log, set the log level to debug or below.

This allows us to analyse and track system behaviour using Odoo’s logging capabilities.

"Unlock the Full Potential of Your Business with Odoo ERP!"

"Get a Cost Estimate for Your ERP Project, Absolutely FREE!"

Get a Free Quote

Leave a Reply

Your email address will not be published. Required fields are marked *