On 31.8.2011. 18:46, Michael Sole wrote:
I have an application that uses a base Database class and then each
class extends that. This gives easy database access to all the classes
and insures that proper logging is maintain by all my developers.

If I create a new instance of the database class directly the logging
works fine, when I create a new instance of the class that extends my
database class I get an error when access any of the log4php log methods.

I can add the getLogger method to each of the parent classes but this is
less than ideal. Is the a way to make log4php methods available given
the use cases I just outlined?

This should not be a problem. I use a similar pattern at work and it works fine. Which error do you get?

Make sure the member variable you keep the Logger object in is protected, and not private. Otherwise, the child object has no access.

Have a look at this proof-of-concept:
http://pastebin.com/rsMSQ6cg

Best regards,
Ivan

Reply via email to