Casper Schmidt Wandahl-Liper , thanks for the suggestion. I am agree with you that implementing classes have extra responsibility to register themselves, however I kept it that way.
LoggerFactory is designed as a static class. In this context, if I use dependency injection (constructor) in
LoggerFactory , that object itself becomes a proxy i.e; the constructor just takes the parameter & assigns it to the static variable (map or whatever it is) in the class
LoggerFactory. After the
static variable is initialized, you can use the
getInstacnce method as shown in the code to get correct logger instance. This way of creating a proxy object which does not get used later did not make a lot of sense. Also if you want to shift the responsibility of registering the logger instances to some other class, that class has to manage the mapping between registration key vs the
.class class instances. How can it do so — by using some
if else logic to assign a
.class for a particular class instance to a reg key or by using a hacky class naming mechanism? I feel it’s all trade off, but I went ahead with the simplified implementation so that developers understand the code well.