Magento 1.9 - Mage::log() isn't creating the log files

Magento 1.9 - Mage::log() isn't creating the log files

August 3, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento 1.9 - Mage::log() isn't creating the log files

Magento 1.9: Resolving Mage::log() Permissions Issue

Hello developers! Today we’re going to tackle an issue that seems to be plaguing many Magento 1.9 users - the mysterious disappearance of log files when using Mage::log(). Don’t worry, by the end of this post, you’ll have a clear understanding of what’s happening and how to fix it.

Understanding the Problem

When working with Magento 1.9, especially while developing custom modules, we often need to write logs for debugging purposes. This is typically done using Mage::log(). However, many developers find that these log files simply aren’t being created, even though the module seems to be running correctly.

What You’ve Tried So Far

You’ve gone through various troubleshooting steps like disabling cache, enabling logging and debugging, adjusting permissions, and even tried different variations of the Mage::log() function. But nothing seems to work!

Why It’s Not Working (Probably)

The issue likely stems from permissions problems in your Magento installation. Even if you’ve changed the ownership of the files using usermod and chown, the log folder might still not have the correct write permissions.

Solving the Permissions Problem

First, let’s understand what we’re aiming for:

  • The log folder (usually named ‘log’) should be owned by the user running your web server. For most Linux servers, this is the ‘www-data’ group.
  • The log folder and its contents need read (r), write (w), and execute (x) permissions for the owner and the group.

Here’s a step-by-step guide to applying these permissions:

Step 1: Change Ownership

Use the following commands to change the ownership of the Magento files to the user running your web server. In this case, we assume it’s ‘www-data’:

sudo chown -R www-data:www-data /path/to/your/magento/installation

Step 2: Adjust Permissions

Now, let’s apply the correct permissions recursively to the files and directories:

find /path/to/your/magento/installation/ -type f -exec chmod 640 {} \;
find /path/to/your/magento/installation/ -type d -exec chmod 750 {} \; 

These commands set the permissions as follows:

  • Files (-f): The owner has read (4) and write (0) permissions, while the group has only read (4).
  • Directories (-d): Both the owner and the group have read (4), write (2), and execute (1) permissions.

Step 3: Adjust Special Folders

Some folders like var and media need special attention:

find /path/to/your/magento/installation/var/ -type f -exec chmod 660 {} \;
find /path/to/your/magento/installation/media/ -type f -exec chmod 660 {} \; 
find /path/to/your/magento/installation/var/ -type d -exec chmod 770 {} \; 
find /path/to/your/magento/installation/media/ -type d -exec chmod 770 {} \;

Step 4: Adjust Includes Folder

Finally, apply the following permissions to the includes directory and its configuration file:

chmod 770 includes
chmod 660 includes/config.php

Why This Works

By changing the ownership of your Magento files to the user running the web server, we ensure that the process can write to them. The specific permissions applied in Step 2 and Step 3 are designed to follow Magento’s security best practices while allowing necessary access.

Conclusion

In most cases, this approach should resolve the Mage::log() issue you’re facing. If you still encounter problems, double-check that the ownership and permissions have been applied correctly in all subdirectories of your Magento installation.

Remember, it’s essential to be cautious when adjusting file permissions, as incorrect settings can lead to security vulnerabilities or system instability. If you’re not comfortable with command-line operations, consider using a graphical file manager tool for Linux or consulting a system administrator.

I hope this guide helps you get back on track with your Magento development! If you found it useful, feel free to share it with your colleagues and give us feedback at Laravel Company. Happy coding!

Magento 1 Cache Security Extensions

Our network