PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
log error message with log package

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> Logging
View previous topic :: View next topic  
Author Message
kalpesh



Joined: 15 Sep 2008
Posts: 7

PostPosted: Mon Nov 10, 2008 2:45 pm    Post subject: log error message with log package Reply with quote

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
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1235

PostPosted: Mon Nov 10, 2008 4:29 pm    Post subject: Re: log error message with log package Reply with quote

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
View user's profile Send private message
kalpesh



Joined: 15 Sep 2008
Posts: 7

PostPosted: Tue Nov 11, 2008 6:56 am    Post subject: problem in error log with pear log Reply with quote

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
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1235

PostPosted: Tue Nov 11, 2008 1:41 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> Logging All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
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



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement