Logging in Odoo: Stop Guessing, Start Tracking!
Have you ever faced a mysterious error in Odoo that just vanished without a trace? Or worse—your custom module fails silently, leaving you clueless about what went wrong? You’re not alone. Many Odoo users and developers struggle with debugging when there’s no visibility into what’s happening behind the scenes.
The solution? Logging.
Logging is like having a black box for your Odoo instance—it records every action, error, and warning so you can trace issues back to their source. Instead of guessing, you’ll have a clear trail to follow. In this guide, we’ll cover:
✅ Why logging is essential in Odoo
✅ How to enable and configure logging
✅ Best practices for effective log management
✅ Pro tips for debugging with logs
By the end, you’ll never have to wonder “What just broke?” again.
Why Logging in Odoo is a Game-Changer
Imagine this: A critical invoice generation feature stops working. Without logs, you’re left checking code, permissions, and database entries blindly. But with logging enabled, you’d see:
ERROR invoice_module: Failed to generate PDF - Permission denied on template.
Boom. Now you know exactly where to look.
Logging helps you:
✔ Catch errors before users report them – Silent failures become visible.
✔ Debug faster – No more "it works on my machine" mysteries.
✔ Monitor performance – Identify slow queries or bottlenecks.
✔ Audit user actions – Track who did what and when.
Without logs, you’re flying blind. With logs, you’re in control.
How to Enable Logging in Odoo
Step 1: Update Your Odoo Config File
Open your Odoo configuration file (usually odoo.conf or config.conf) and add:
log_level = debug
log_handler = :DEBUG
log_levelsets the lowest level of logs to record (debug,info,warn,error,critical).log_handlerspecifies which modules to log. Use:DEBUGfor everything or target specific modules likeodoo.addons:DEBUG.
Step 2: Restart Odoo
After saving the config file, restart your Odoo server:
sudo service odoo restart
Now, Odoo will start recording detailed logs in /var/log/odoo/odoo.log (location may vary).
Step 3: Check the Logs
Use terminal commands like tail to monitor logs in real-time:
tail -f /var/log/odoo/odoo.log
Or filter logs for errors only:
grep "ERROR" /var/log/odoo/odoo.log
Advanced Logging: Custom Python Loggers
If you’re developing custom modules, you can add dedicated loggers in your Python code:
import logging
_logger = logging.getLogger(__name__)
def process_invoice(self):
try:
# Your code here
_logger.info("Invoice processed successfully!")
except Exception as e:
_logger.error("Failed to process invoice: %s", str(e))
This helps you:
🔹 Track specific module behavior
🔹 Log custom success/failure messages
🔹 Debug complex workflows
Best Practices for Effective Logging
Avoid Log Spam
- Don’t log everything at
DEBUGin production—it slows down the system. - Use
INFOfor general tracking andERRORfor critical issues.
- Don’t log everything at
Rotate Logs Regularly
- Large log files consume disk space. Use
logrotateto archive old logs.
- Large log files consume disk space. Use
Use Structured Logging
- Format logs consistently (e.g.,
[MODULE] [LEVEL] Message) for easier filtering.
- Format logs consistently (e.g.,
Monitor Logs Automatically
- Tools like Sentry or ELK Stack can alert you to critical errors.
How Do You Use Logs?
Logging is a powerful tool, but everyone has their own tricks.
🔍 Do you use a log management tool?
🔍 Have logs ever saved you from a major Odoo disaster?
Share your best logging tips in the comments!
Final Thought: Stop Guessing, Start Tracking!
Logging turns Odoo debugging from a frustrating mystery into a straightforward investigation. With just a few config tweaks, you’ll have full visibility into your system’s behavior—saving you hours of headaches.
🚀 Ready to take control? Update your odoo.conf today and never lose track of an error again!