|
Newest Member
|
|---|
| lakesarearxy | |
| cool Statistics |
| | coolcommands: | 1313 | | Categories: | 82 | | Total queries: | 520075 | | Members: | 4219 | |
|
|
|
 |
|
|
Search coolcommands.com
 |
Submitted by:
lvo   |
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
|  |  |  |  |
|
|
|
|
 |
|
|
|
Top 5 Submitters
|
|---|
| lvo | 1138 |
| audet | 37 |
| kah00na | 32 |
| Mariom | 24 |
| lebjf000 | 13 |
Top 5 Searches
|
| Category Solaris | 42391 |
| Category AIX | 37496 |
| Category General UNIX | 33769 |
| solaris | 20551 |
| aix | 19172 |
|
|
|
|