Why do you think it should be? What about a regular non-static class that can be created on demand? And then create the only static instance available as the default registrar. Thus, you get the best of both worlds: convenient global access to the logger and the ability to test or temporarily use another registrar.
Another suggestion is to simply create one instance and pass it as a parameter to each component of your class, as @disown suggests.
But if you make the class itself static or solitary, you simply shoot in the foot.
Edit
For example, in response to @Stephen's comment:
// define a logger class, a perfectly ordinary class, not a singleton, and without all static members class Logger { // .... }; // create a single global *instance* of this class Logger defaultLog; void foo() { // and now use the globally visible instance defaultLog.Log("hello"); // or create a new one if that what we need: Logger newlog; newlog.Log("hello"); }
There is no magic. This is exactly what the standard library does. std::cout not single. This is just a global instance of the std::ostream class, a class that can also be created in the usual way, if and when you need it.
source share