static log4cxx::LoggerPtr logger


Is it a good practice put a log4cxx into private member and static it,
like below ?

class SomeClass {
private:
static log4cxx::LoggerPtr logger;

}

I have never static log4cxx, neither put it in private member.

Thank you
You might want to explain to us what log4cxx is and how you are specifically using it.

Assuming it's some typedef for a pointer to a "Logger" object: By itself, there's nothing wrong with putting a pointer as a member of a class, but you should make sure that you know who is in charge of deleting the data that the pointer points to, and you need to make sure that the pointer never goes stale (starts pointing to data that is no longer valid).

If that data is being shared across different objects, you might want to consider using an std::shared_ptr, depending on your design.
Topic archived. No new replies allowed.