Cannot open file for writing log

Need help upgrading your Joomla! website or converting to Joomla! 3.x?

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
milesreid
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Wed May 15, 2013 3:17 pm
Location: Leeds, UK
Contact:

Cannot open file for writing log

Post by milesreid » Wed May 15, 2013 3:31 pm

I have just uploaded my Joomla 3.1.1 installation from my development pc to my production linux server. The front end is looking fine, but I when I try to login as administrator, I get the message

0 Cannot open file for writing log

The webserver is Apache. I assume that this is a permissions issue, and have given the following folders 777 permissions:

logs
tmp
administrator/cache

The relevant lines from my configuration.php file are
public $tmp_path = '/tmp';
public $log_path = 'logs';
(both as default)

What am I missing here?
Any help gratefully received
Miles

User avatar
JER3
Joomla! Apprentice
Joomla! Apprentice
Posts: 41
Joined: Sun May 05, 2013 9:24 am
Contact:

Re: Cannot open file for writing log

Post by JER3 » Wed May 15, 2013 9:50 pm

Have you updated the path for $log_path and $tmp_path in the configuration.php file in your site's root folder?
Regards,
Barbara

milesreid
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Wed May 15, 2013 3:17 pm
Location: Leeds, UK
Contact:

Re: Cannot open file for writing log

Post by milesreid » Thu May 16, 2013 9:10 am

Thanks Barbara.
I sorted out the problem by deleting the configuration.php file, re-running the installation and then importing the data from a backup.

I found out that the error had been caused by the values assigned to the $log_path and $tmp_path variables - I had used a path relative to the web root and not absolute values.
Correct values were

$log_path = '/var/www/vhosts/mysite.com/subdomains/clients/httpdocs/Sacred/logs';
$tmp_path = '/var/www/vhosts/mysite.com/subdomains/clients/httpdocs/Sacred/tmp';

Many thanks for your help
Miles

rasputino
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Thu Jan 24, 2013 3:14 pm

Re: Cannot open file for writing log

Post by rasputino » Mon Sep 30, 2013 10:47 am

My problem was that the "logs" directory was used by my hosting company, and I had no access to this directory.


I created a new directory called "binnacles", and changed the path in configuration.php to this directory:

public $log_path = '/homepages/2/d353530289/htdocs/binnacles';

User avatar
leolam
Joomla! Master
Joomla! Master
Posts: 20652
Joined: Mon Aug 29, 2005 10:17 am
Location: Netherlands/ Germany/ S'pore/Bogor/ North America
Contact:

Re: Cannot open file for writing log

Post by leolam » Tue Oct 01, 2013 5:38 pm

For those who face these issues:

To find out what your absolute path is, copy the following code into a text editor (i.e. JEdit, Notepad, etc), save the file as a .php naming it whatever you prefer (i.e anyfilename.php.).

Code: Select all

<?php 
 $path = getcwd();
 echo "Your Absoluthe Path is: ";
 echo $path;
 ?>
Using your FTP software, ftp the file you have just created to your root folder.

Open your web browser and type in http://www.yourdomain.com/anyfilename.php. The result will show the absolute path!

IMPORTANT: For security reasons, delete this file as soon as you have ascertained the information you require.

Leo 8)
Joomla's #1 Professional Services Provider:
#Joomla Professional Support: https://gws-desk.com -
#Joomla Specialized Hosting Solutions: https://gws-host.com -

Hermannsson
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Fri Jan 31, 2014 4:49 pm

Re: Cannot open file for writing log

Post by Hermannsson » Fri Jan 31, 2014 4:51 pm

leolam: You are my hero today, thanks a lot. Your post solved my sitepain :-)

firejunky
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Wed Mar 23, 2011 5:03 pm

Re: Cannot open file for writing log

Post by firejunky » Thu Feb 13, 2014 6:04 pm

Thanks leolam,

I moved my site to a new host and got the error mentioned above "0 Cannot open file for writing log". I used your absolute path code to find my new server's path and was able to fix the path to my $log_path and $tmp_path in configuration.php. Thanks again.

vanguardkarthik
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Wed Mar 26, 2014 7:07 am

Re: [SOLVED] Cannot open file for writing log

Post by vanguardkarthik » Wed Mar 26, 2014 7:15 am

The reason is some time your hosting providers log folder and the joomla log folder is same.
You cannot change permission hosting providers "logs" folder.

Alternatively you create the log folder example "joomlalogs" in joomla installed root path and set the permission 777.
After that set the log folders path in configuration.php example "public $log_path = '/www/homepages/htdocs/joomlalogs';

Make it simple

sovainfo
Joomla! Exemplar
Joomla! Exemplar
Posts: 8808
Joined: Sat Oct 01, 2011 7:06 pm

Re: Cannot open file for writing log

Post by sovainfo » Wed Mar 26, 2014 8:01 am

It is always bad advice to set folders to 777. There is never, ever a need to do so!
Issue with migrating? Include logs/joomla_update.php in your report!
Blank screen? Verify pagesource for HTML code (javascript error)
Installation failing on populating database? Install with set_time_limit(0)
Document your customizations!

User avatar
ISScyborg
Joomla! Intern
Joomla! Intern
Posts: 76
Joined: Mon Jun 04, 2012 1:40 pm
Location: Slovenia
Contact:

Re: Cannot open file for writing log

Post by ISScyborg » Tue Apr 08, 2014 12:03 pm

I have same problem, when I try to update Joomla from 3.2.2 on 3.2.3

cannot open file for writing log
Image

logs path and tmp path are good, I do not know what is wrong?

Image

_Arthur_
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Sun Apr 27, 2014 12:24 pm

Re: Cannot open file for writing log

Post by _Arthur_ » Sun Apr 27, 2014 1:34 pm

Hi ISScyborg,

did you solved your problem? I've the same problem too (trying to update from 2.3.2 to 2.3.3 --> look here) in the German area ...

Ciao Arthur

pcproffitt
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Tue Oct 18, 2005 1:33 pm

Re: Cannot open file for writing log

Post by pcproffitt » Fri May 02, 2014 3:15 pm

I had this same issue trying to update from 3.2.3 to 3.3.0. I found a message in the error log indicated Joomla could not open the file logs/joomla_update.php. Turns out the permissions on that file were not correct for the environment. Once corrected the update continued as expected. Hope that is helpful to others.

nanjicong
Joomla! Intern
Joomla! Intern
Posts: 50
Joined: Sun Aug 04, 2013 11:41 am

Re: Cannot open file for writing log

Post by nanjicong » Wed May 14, 2014 7:40 am

leolam, you are the superstar.
leolam wrote:For those who face these issues:

To find out what your absolute path is, copy the following code into a text editor (i.e. JEdit, Notepad, etc), save the file as a .php naming it whatever you prefer (i.e anyfilename.php.).

Code: Select all

<?php 
 $path = getcwd();
 echo "Your Absoluthe Path is: ";
 echo $path;
 ?>
Using your FTP software, ftp the file you have just created to your root folder.

Open your web browser and type in http://www.yourdomain.com/anyfilename.php. The result will show the absolute path!

IMPORTANT: For security reasons, delete this file as soon as you have ascertained the information you require.

Leo 8)

designer156
Joomla! Apprentice
Joomla! Apprentice
Posts: 42
Joined: Sun May 17, 2009 1:00 am

Re: Cannot open file for writing log

Post by designer156 » Thu Jun 12, 2014 11:32 am

Worked for me too - had not updated the configuration.php file correctly after a migration to a new host. Found the path using the code below and updated the configuration.php file. Job done.

leolam wrote:For those who face these issues:

To find out what your absolute path is, copy the following code into a text editor (i.e. JEdit, Notepad, etc), save the file as a .php naming it whatever you prefer (i.e anyfilename.php.).

Code: Select all

<?php 
 $path = getcwd();
 echo "Your Absoluthe Path is: ";
 echo $path;
 ?>
Using your FTP software, ftp the file you have just created to your root folder.

Open your web browser and type in http://www.yourdomain.com/anyfilename.php. The result will show the absolute path!

IMPORTANT: For security reasons, delete this file as soon as you have ascertained the information you require.

Leo 8)

xshmonx
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Fri Aug 15, 2014 9:10 pm
Contact:

Re: Cannot open file for writing log

Post by xshmonx » Fri Aug 15, 2014 9:16 pm

Thanks leolam! Worked for me!
Last edited by pe7er on Fri Aug 15, 2014 10:37 pm, edited 1 time in total.
Reason: manual signature has been removed

lelogrott
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Wed Sep 10, 2014 10:17 pm

[HELP] Cannot open file for writing log

Post by lelogrott » Wed Sep 10, 2014 10:28 pm

Hey guys, i REALLY need your help!

i'm getting the same error message, already checked the paths (both of them), and the permissions! and still nothing.

buut, theres a few details. my host have the 3.10 php version and the joomla that i'm using needed 3.10.1. this is one academic website, so i can't say to the manager update it, is not that easy.

so i re-write the configuration.php files (administrator too). the site is on http://labp2d.joinville.udesc.br

but when i try to log, that error pops out.

sorry about any "language mistake"

please, help me.

stinson
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Mon Sep 15, 2014 12:14 pm

Re: Cannot open file for writing log

Post by stinson » Fri Sep 19, 2014 12:16 pm

Hey,

I get the same error when I log in to my joomla website.

The last thing I did bevore I logged out was changing the eMail sending settings (smtp, account name and so on). Then I saved it. And logged out.

Next time I logged in the message occured.

Already tried changing the path (leolams idea). No success.

Some additional information that may be useful:

1. A friend hosts my site on his server. I started to build my joomla page on my own PC with xampp. I gave him the files and he managed it. It worked all fine until I was changing the settings (eMail sending and so on).

2. When I check the old directory of xampp (xampp/apps/joomla) and go in the tmp or log folder: there are No files. When I checked into the ftp folder where my site is hosted there are two files: /tmp/index.html and logs/index.html .

3. configuration.php : bevore I changed anything there (bevore leolams idea) there still were the old directories when I used joomla in xampp on my own PC (D:/xampp/apps/joomla/tmp or .../logs). But the site was working.

4. configuration.pho : there are no entries at all ftp entries ( public $ftp_host = ''; ...port, user, pass, root neither).


I would realy appreciate it if someone could help me in this case.

Thanks. Stinson.

stinson
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Mon Sep 15, 2014 12:14 pm

Re: Cannot open file for writing log

Post by stinson » Fri Sep 19, 2014 12:31 pm

Additional info I just found out that may be useful:

It seems that I cant change any permission of the original joomla folders or files.

sovainfo
Joomla! Exemplar
Joomla! Exemplar
Posts: 8808
Joined: Sat Oct 01, 2011 7:06 pm

Re: Cannot open file for writing log

Post by sovainfo » Fri Sep 19, 2014 3:28 pm

Ask your friend to change configuration.php and put proper values in for $log and $tmp. It seems you are not allowed to do that.

Verify with System->System Information->Directory Permissions whether those folders are writable. They must be!

You could try to enable the FTP layer in Global Configuration. Your webserver doesn't have write access to its filesystem. Provide the host/user/pw and try to save. When credentials are correct it should allow you to do that. This assumes you have FTP access to your webspace. Did you try with FileZilla?
Issue with migrating? Include logs/joomla_update.php in your report!
Blank screen? Verify pagesource for HTML code (javascript error)
Installation failing on populating database? Install with set_time_limit(0)
Document your customizations!

stinson
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Mon Sep 15, 2014 12:14 pm

Re: Cannot open file for writing log

Post by stinson » Wed Sep 24, 2014 8:36 am

Hi sovainfo!

Thanks for the reply!
-------
Important information about the problem: When I go to the login page http://www.....com/administrator/ and type in ANY combination of username and password and "Log in" it gets me to the page: Error - An Error occured - 0 Cannot open file for writing log (see attached picture).
--------

I was able to change the configuration.php (and change the paths of tmp and log).
Verify with System->System Information->Directory Permissions whether those folders are writable. They must be!
Could you explain which directory to check and where (my Windows, Joomla (can't get to System configuration), or with FileZilla?)? I guess you mean in Joomla.
You could try to enable the FTP layer in Global Configuration. Your webserver doesn't have write access to its filesystem. Provide the host/user/pw and try to save. When credentials are correct it should allow you to do that. This assumes you have FTP access to your webspace. Did you try with FileZilla?
I do have FTP (sftp) access to my webspace and I use FileZilla. "enable the FTP layer in Global Configuration" -> I can't get access via the joomla interface. Is there a way to change it manually via FTP files?

Thanks for your help!

Stinson.

Edit: sorry for the link -.-
You do not have the required permissions to view the files attached to this post.

stinson
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Mon Sep 15, 2014 12:14 pm

Re: Cannot open file for writing log

Post by stinson » Wed Sep 24, 2014 8:46 am

Update: Global Configuration = configuration.php
Changed following values:

public $ftp_host = '....com';
public $ftp_port = '22';
public $ftp_user = 'xxx';
public $ftp_pass = 'xxx';
public $ftp_root = '/var/www/xxx/';
public $ftp_enable = '1';

xxx -> just for the forum of course.

Result: Now when I log in it takes longer to load but I get the same error page.

sovainfo
Joomla! Exemplar
Joomla! Exemplar
Posts: 8808
Joined: Sat Oct 01, 2011 7:06 pm

Re: Cannot open file for writing log

Post by sovainfo » Wed Sep 24, 2014 4:02 pm

Looks like the webserver is not properly configured. Try FPA as mentioned in the header of the board.
Issue with migrating? Include logs/joomla_update.php in your report!
Blank screen? Verify pagesource for HTML code (javascript error)
Installation failing on populating database? Install with set_time_limit(0)
Document your customizations!

User avatar
H13
Joomla! Ace
Joomla! Ace
Posts: 1545
Joined: Sun Dec 10, 2006 6:39 pm
Location: Czech Republic
Contact:

Re: Cannot open file for writing log

Post by H13 » Sun Nov 16, 2014 10:45 pm

Hi, getting the same problems like others above on one of the test server:

Cannot open file for writing log

When I changed the log folder to 777, everything is OK, so this seems to be permissions problem not the path problem.

The problem is, the site is working with FTP layer and it works OK

When I look at:

libraries\joomla\log\logger\formattedtext.php

I see:

Code: Select all

if (!$this->file = fopen($this->path, 'a'))
		{
			throw new RuntimeException('Cannot open file for writing log');
		}
		if ($head)
		{
			if (!fwrite($this->file, $head))
			{
				throw new RuntimeException('Cannot fput file for log');
			}
		}
Which seems to be not compatible with FTP layer (no JFile, no JFolder, etc. ???)

Can somebody confirm this?

Thank you, Jan
- Phoca Cart - Joomla eCommerce App - https://www.phoca.cz/phocacart
- Phoca Gallery - powerful image gallery
- Phoca Restaurant Menu - https://www.phoca.cz/phocamenu
- Phoca Download - download manager for Joomla

User avatar
H13
Joomla! Ace
Joomla! Ace
Posts: 1545
Joined: Sun Dec 10, 2006 6:39 pm
Location: Czech Republic
Contact:

Re: Cannot open file for writing log

Post by H13 » Mon Nov 17, 2014 12:00 am

For those who need to write Log entries with FTP layer
(be aware, writing files and their content with FTP layer takes more memory resources than not using FTP layer)

EDIT:
libraries\joomla\log\logger\formattedtext.php

method:
public function addEntry(JLogEntry $entry)
http://www.phoca.cz/joomla/api/class-JL ... #_addEntry

FROM:

Code: Select all

if (!fwrite($this->file, $line . "\n"))
		{
			throw new RuntimeException('Cannot write to log file.');
		}
TO:

Code: Select all

jimport('joomla.filesystem.file');// can be set in header
$content = '';
		if (JFile::exists($this->file)) {
			$content = file_get_contents($this->file);
		}
		$content = $content . $line . "\n";
		if (!JFile::write($this->file, $content)) {
			throw new RuntimeException('Cannot write file for log');
		}

method:
protected function initFile()
http://www.phoca.cz/joomla/api/class-JL ... #_initFile

FROM:

Code: Select all

if (!$this->file = fopen($this->path, 'a'))
		{
			throw new RuntimeException('Cannot open file for writing log');
		}
		
		if ($head)
		{
			if (!fwrite($this->file, $head))
			{
				throw new RuntimeException('Cannot fput file for log');
			}
		}
TO:

Code: Select all

jimport('joomla.filesystem.file');// can be set in header
$content = '';
		if (JFile::exists($this->path)) {
			$content = file_get_contents($this->path);
			$this->file = $this->path;
		}
		
		if ($head){
			$content = $content . $head;
			if (!JFile::write($this->path, $content)) {
				throw new RuntimeException('Cannot write file for log');
			}
		}
- Phoca Cart - Joomla eCommerce App - https://www.phoca.cz/phocacart
- Phoca Gallery - powerful image gallery
- Phoca Restaurant Menu - https://www.phoca.cz/phocamenu
- Phoca Download - download manager for Joomla

makevalue
Joomla! Apprentice
Joomla! Apprentice
Posts: 45
Joined: Wed Jun 04, 2008 5:24 pm
Location: Ventura County

Re: Cannot open file for writing log

Post by makevalue » Sat Jan 17, 2015 10:32 pm

leolam wrote:For those who face these issues:

To find out what your absolute path is, copy the following code into a text editor (i.e. JEdit, Notepad, etc), save the file as a .php naming it whatever you prefer (i.e anyfilename.php.).

Code: Select all

<?php 
 $path = getcwd();
 echo "Your Absoluthe Path is: ";
 echo $path;
 ?>
Using your FTP software, ftp the file you have just created to your root folder.

Open your web browser and type in http://www.yourdomain.com/anyfilename.php. The result will show the absolute path!

IMPORTANT: For security reasons, delete this file as soon as you have ascertained the information you require.

Leo 8)
Cool beans Leo
;D

User avatar
willkey
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 147
Joined: Mon Feb 25, 2008 6:02 pm
Location: Huntington, Vermont
Contact:

Re: Cannot open file for writing log

Post by willkey » Wed Feb 25, 2015 6:09 pm

this worked, thank you!
rasputino wrote:My problem was that the "logs" directory was used by my hosting company, and I had no access to this directory.


I created a new directory called "binnacles", and changed the path in configuration.php to this directory:

public $log_path = '/homepages/2/d353530289/htdocs/binnacles';

atodd
Joomla! Apprentice
Joomla! Apprentice
Posts: 17
Joined: Thu Feb 10, 2011 4:14 pm

Re: Cannot open file for writing log

Post by atodd » Fri Feb 27, 2015 4:32 pm

rasputino wrote:My problem was that the "logs" directory was used by my hosting company, and I had no access to this directory.


I created a new directory called "binnacles", and changed the path in configuration.php to this directory:

public $log_path = '/homepages/2/d353530289/htdocs/binnacles';
I have this same problem but it didn't help when I created a new folder and changed my configuration.php file. I am trying to update from 2.5.28 to 3.4 and it fails every time. The error says that it cannot open /logs/index.html because it is not writable. For some reason, Joomla keeps looking for that file (which doesn't exist) and I can't seem to change it! The site is on 1and1 and they have that logs folder locked down so I can't do anything with it.

Any help would be greatly appreciated!

User avatar
willkey
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 147
Joined: Mon Feb 25, 2008 6:02 pm
Location: Huntington, Vermont
Contact:

Re: Cannot open file for writing log

Post by willkey » Sat Feb 28, 2015 3:46 pm

please follow these instructions to a "T" - also check with your template provider to see what their template upgrade might require. Changing the default front end template to one that ships with Joomla is key, so use Beez or something before you upgrade.
https://docs.joomla.org/Joomla_2.5_to_3 ... _Migration

atodd
Joomla! Apprentice
Joomla! Apprentice
Posts: 17
Joined: Thu Feb 10, 2011 4:14 pm

Re: Cannot open file for writing log

Post by atodd » Tue Mar 17, 2015 1:46 pm

I have followed the instructions to a "T" and still get the same error. I really don't think it matters how well anyone follows the instructions. The logs folder is locked down and Joomla wants to write to it. So it sounds to me like a modification to the Joomla core could fix the problem. Of course, I have no idea where I could change it to point to a different folder. Anyone have any other ideas?

User avatar
willkey
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 147
Joined: Mon Feb 25, 2008 6:02 pm
Location: Huntington, Vermont
Contact:

Re: Cannot open file for writing log

Post by willkey » Tue Mar 17, 2015 11:24 pm

try making a new folder, with a new name, like "mylogs" and use that for the /logs variable in the configuration file


Locked

Return to “Migrating and Upgrading to Joomla! 3.x”