 |
|
|
| View previous topic :: View next topic |
| Author |
Message |
kalpesh
Joined: 15 Sep 2008 Posts: 7
|
Posted: Mon Nov 10, 2008 2:45 pm Post subject: log error message with log package |
|
|
hi,
I want to log errors in file.
I try to log exceptional error but it doesn't log error in file.
i am using database class using DB package in which one function is below :
| Code: |
require_once('DB.php');
require_once('Log.php');
$conf = array('mode' => 0600, 'timeFormat' => '%X %x');
$file_error = &Log::singleton('file', 'out.log', 'ident', $conf);
public function select($sql)
{
$result=$this->conn->query($sql);
if(DB::isError($result))
{
$file_error->log($sql);
//we are not connected. Throw an exception
throw new Exception($this->conn->getMessage(),$this->conn->getCode());
}
|
Please help me thanks in advance. |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1210
|
Posted: Mon Nov 10, 2008 4:29 pm Post subject: Re: log error message with log package |
|
|
| kalpesh wrote: | I want to log errors in file.
I try to log exceptional error but it doesn't log error in file. |
Are you sure that the server is allowed to (create and) write out.log in the current directory? |
|
| Back to top |
|
 |
kalpesh
Joined: 15 Sep 2008 Posts: 7
|
Posted: Tue Nov 11, 2008 6:56 am Post subject: problem in error log with pear log |
|
|
When i try to log application info then it will write in out.log file.
The problem occurs when i try to log error.
The error that occured is call to log() function from a non-object.
But I already created $file_error object in that file.
Please help me .
Thanks in advace. |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1210
|
Posted: Tue Nov 11, 2008 1:41 pm Post subject: |
|
|
Ah sorry, didn't notice that you're calling log() inside a function.
You have declared the log instance (i.e. $file_error) outside of this function. If you now want to use it inside the function, you can either use "global $file_error;" at the beginning of the function or pass $file_error as a parameter to the function. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|