.net - Singleton, Logging and Global Settings - Good or Bad implementation? -
I have a logging class that requires calling almost everywhere in the application.
Although it is "way to write", "log level" and if it is "enabled" or not, then the setup of the application is required at the beginning of it.
I do not want to give this criteria every time or pass the logging class as the parameter of each object in my application, so I use the singleton pattern for logging.
Recently I have suffered a lot from tightly coupled sections, I do not want to do this again, but it is the only good solution after thinking about these sounds.
Update:
I do not really care about logging, which I resolve issues of similar care , I am doing the same dilemma with another global setting object which is necessary to use from so many classes, but in each one of them, only one terrible overhead and less readable code comes in.
What do you think of this implementation and when you come into the same design decisions, what do you do?
P.S. Please do not give some suggestions like "Use the Loose 4 X Library" and so on.
First - you can write log author as a trace listener, Trace from more methods Use etc?
Do you really need an example? It would be useful, for example, if you want to summarize it as TextWriter or similar - but if it is going to be a single singleton, then what methods are not used directly in a stable way Can be done, i.e. Log.Write (...) (instead of being lost in a log example)?
General problem again - it depends on the types of logging that are being done for the "Manager" (etc) sections, you can automate it to depend on injection (Unity, StructureMap, etc.) You can consider using it. I usually do not use injection with DTO, however.
Comments
Post a Comment