coolcommands.com - the search engine for unix sysadmins :: unix commands and scripts
Friday July 30, 2010


 Home
 Search
 Advanced Search
 Category Search
 Affiliates
 Acknowledgements
 Cool Links

Username

Password

Remember me
Forgot your password?
Create an account

Who's Online
We have 25 guests online

Newest Member

lakesarearxy

Hit Counter
4550145 Visitors

cool Statistics
coolcommands:1313
Categories:82
Total queries:520075
Members:4219





Search coolcommands.com
Search Keyword:


coolcommand

log.php - php include file to do logging to a text file
Description

This is a PHP include file which does logging of messages to a central logfile. You can use it in all your applications to avoid writing the same code over and over.

Some things to change are:

1) Path and name of logfile
2) Create the logfile before using this function
3) Ensure the file is writable by the user your web server runs as (usually nobody)

To include this file in your PHP pages when you want to do logging, simpy add this line at the top of your PHP page:

require('log.php');

To call the logging function, use this line in your PHP page:

log_action("Your logging message here.\n");

Include code for log.php:

<?php

function log_action($msg) {
if ($fp = @fopen("/var/lib/mysql/php_app.log", "a")) {
fwrite($fp, $msg, strlen($msg));
fclose($fp);
}
}
?>

NOTE: You can also use variables from your PHP page in the logfile message text.
Example

log.php

Return to search results

Random coolcommands

coolcommand: psradm - how to change processor operational status in Sun Solaris
Example: psradm -a -n
[show me the details]
coolcommand: logform - format a jfs log on IBM AIX
Example: logform /dev/qmarvg01lv01
[show me the details]
coolcommand: fw - how to display the status of target hosts in Checkpoint Firewall-1
Example: fw stat
[show me the details]
coolcommand: how to connect to an Oracle database
Example: sqlplus joe/mypwd@orainstance
[show me the details]

coolcommands.com - the search engine for UNIX sysadmins :: unix commands and scripts



FREE
myPMS

Password
Management
System

by

LVOware.com




Top 5 Submitters

lvo1138
audet37
kah00na32
Mariom24
lebjf00013

Top 5 Searches

Category Solaris42391
Category AIX37496
Category General UNIX33769
solaris20551
aix19172

Terms of Use
Privacy
Contact


 
coolcommands.com © 2010. All Right Reserved.
Programming by PRATTICO Consulting . Hosting by Apricusum