Imagine I have the following situation:
File1.php
Function.php
debug_backtrace() can be used to trace back through the call stack. It can be slow though, so be careful with it if you're doing a lot of logging.
If you're using PHP 5.3, you could take advantage of late static binding and have a base class method of log(), and your child classes could call it but still maintain static references to __FILE__ and __LINE__.
A final option would be just pass __FILE__ and __LINE__ in as parameters when you call your log() function.