/    Sign up×
Community /Pin to ProfileBookmark

writing log files in PHP

Hello

I have written my own logging mechanism that allows me to send debug messages to a local file.
That worked fine on Windows.

I am now moving my application to a Linux environment and would like to know how can I write my code so that it will work seamlessly on both operating system.

Each operating system defines its file structure differently.

Can I check on what operating system I am running and refer the debug message to the appropriate log file?

Or maybe there is a known (not to me) logging system in PHP that I could utilize. That system would generate log files regardless of the operating system it is used on.

regards
David

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@AdamGundryJul 21.2004 — Would the [url=http://www.php.net/error_log]error_log()[/url] function do what you are looking for?

Adam
Copy linkTweet thisAlerts:
@JavaHead_JonnieJul 21.2004 — Something like:
[code=php]
...

$result = mysql_query($some_query);
if (!result)
{
error_log("Invalid query: " . mysql_error() . "", 3, "/var/tmp/mysql-errors.txt");
}[/code]
Copy linkTweet thisAlerts:
@davidklonskiauthorJul 21.2004 — this solution would work fine on a Linux.

What if I would want the system to run seamlessly on both Linux and Window?
×

Success!

Help @davidklonski spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...