By: Anusha

Logging in Odoo 13

Technical Odoo 13 SourceCode

Logging is one of the most important tools for analyzing what are the things happening inside our odoo server while running the service. In most of the case by analyzing the server log we can get a clear idea regarding an error or any bug. So we can check how these log messages can be added to our custom modules.

Import logging

_logger = logging.getLogger(__name__)

Before starting the first thing we need to remember is to import a module from the python standard library i.e.  ‘logging’. If we want to use a logging option we need to import this python module.

Here _logger object is initialized by the name of the current code file, __name__.

Now we can check different types of log levels


        logs a message with level DEBUG on this logger


        logs a message with level WARNING on this logger


        logs a message with level INFO on this logger


        logs a message with level ERROR on this logger


        logs a message with level CRITICAL on this logger

So we can check the examples on how we can define this. For this, I am putting this log messages under my custom function in my custom module.

import logging

_logger = logging.getLogger(__name__)
class CustomModel(models.Model):
_name = ‘custom.model’

In the below method I am going to define the log messages.

def _onchange_custom_field(self):
    _logger.debug("IT IS DEBUG")
    _logger.info("IT IS INFO")
    _logger.error("IT IS Error")
    _logger.warning("IT IS warn")
    _logger.critical("IT IS Critical")

Here my module name is product_parameter  and the code is in the file product.py whose path is product_parameter/models/product.py. Now let's check the server log


From the log message itself, we can get an idea regarding the file path where this log message is showing Ie odoo.addons.product_parameter.models.product. It helps the user to identify the bug/error easily.

Other Logging options

We have different options for logging. So this can be configured in our odoo conf file.

logfile = None // Specify the log file to store the log details. 

log_handler = LEVEL: LEVEL // set up a handler at LEVEL for a given PREFIX.  

For example, if you want to have DEBUG level for module product_parameter only, you can run it with parameter:


log_level  = info // specify the level of the logging.

log_db_level  = warning // Logging database level.

log_db  = False // Specify the Logging database.

If you need any assistance in odoo, we are online, please chat with us.

cybrosys youtube



Leave a comment


Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635


Cybrosys Limited
Alpha House,
100 Borough High Street, London,
SE1 1LB, United Kingdom


Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.


Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message