I have two classes in my project that I would like to pass the logger from the main class to the sub-class and have the sub-class utilise the parent's logger settings.
The sub-class is a separate, generic class (i.e. not tied to the main class) and must be able to create it's own logger if there isn't one provided.
The main class creates a logger, adds a console handler, file handler and log formatter, and I would like the sub-class to be able to temporarily override the log formatter for it's log messages and then when the main class resumes, revert to it's log formatter.
I've tried to lass the logger to the sub-class, or create a new one if required, but I get multiple messages on screen and in the log file (it seems to be appending the handlers to the main class rather than over-riding it).
How would I go about doing this?