CFLOG and Permissions

This post is more than 2 years old.

Here is an issue I've run into a few times in the recent months and I've never figured it out till now. Thanks go to cfconcepts@twitter for pointing me in the right direction.

From time to time I've noticed that cflog would suddenly stop working. It wouldn't throw an error it just wouldn't... log. I was never able to nail down exactly what the issue was, but today I really wanted to dig into it. I threw out a message on twitter and cfconcepts mentioned that I should check permissions.

Now - at first - I was sure he (or she) was wrong. Obviously if cflog tried to write to a file that it didn't have permissions for - it would cfthrow, right? Nope. Apparently cflog silently fails.

How did I get a permissions issue in the first place? I run cf/apache on startup on my Mac. But from time to time I have to stop and restart them. I sometimes use the command line and sometimes use the graphical tools for this. I had stopped and restarted CF as a normal user. When I restarted it using sudo it was suddenly able to write to the file again.

Anyone else encounter this? Obviously those of you on Windows probably never see this.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Archived Comments

Comment 1 by Steven Erat posted on 5/9/2008 at 1:37 AM

I was about to comment that it doesn't matter how you start ColdFusion because it su's to the runtime user, and always runs as that user.

But then, checking my facts, I read the ColdFusion start script in bin/ and found that Mac has different rules than Linux or Unix. In the section where the script checks for user id 1 for root, there's a comment that says:

"#nothing, on OSX we don't care about the user name. We assume that the user running it has permission to do everything"

Then further down there's an if block that checks the operating system and for Unix and Linux it does an "su - $RUNTIME_USER", but on Mac it doesn't... It just starts the server without su, meaning that ColdFusion is running as the user that started it. I never quite realized this before.

Then it makes sense that CFLOG's permission depends on the account that starts the server.

Comment 2 by Raymond Camden posted on 5/9/2008 at 1:56 AM

Would that be a bug in the script then?

Also - does it make sense for cflog to just silently fail?

Comment 3 by Will B. posted on 5/9/2008 at 2:05 AM

It would be my thought that cflog, yes, should silently fail. Most people would use cflog for logging errors. So if it throws an error, too...uh, oh!

- WB

Comment 4 by Steven Erat posted on 5/9/2008 at 7:08 AM

I would expect that CFLOG would behave the same as CFFILE. The latter would throw an exception if the process didn't have permission, and so should the former... at least that's my logic. I'll look into it tomorrow.