I'm working on an API with Symfony and FosRestBundle.
In my ApiController, I want to log all exception in a specific file: api.log
Here an example of my code:
public function getUserAction($param){
if(is_int($param)){
$user = $this->getDoctrine()->getRepository('ProjectBundle:Account')->findOneById($param);
}
else{
$user = $this->getDoctrine()->getRepository('ProjectBundle:Account')->findOneByUsername($param);
}
if(!is_object($user)){
return "User Not Found";
}
return $user;
}
Where i need to catch and log the exeption ? In if(!is_object($user)){ or when i retrieve $user ? And How can i save and log the exeption in my file api.log ?
Thanks !