I would like to understand how can I configure the same appender for two different namesapaces.
I have:
WPF.Client.Foo class in first dll
WPF.Server.Foo class in second dll
I want all logs in both classes to be traced with same appender to the same file.
Currently I passed the same string to the ILog in both classes but I don't like it because in the future maybe I will need to change this name or add additional dlls. I can't use a constant because every dll is independent and do not have references to any other dll.
I don't want to configure two loggers with same appender (and different name/namespase) in the Logger.config file because if the logs are enabled, it should be always enabled for both Dlls and I don't want to update two thresholds in the config file.
Merging the code to one dll is not an option.
Am I wondering if there is an easy way to configure many namespaces to same appender when the namesapaces are completely different and not a child of each other.
Thank you.
You can set up an
appenderlinked to therootlogger, and let theappenderdo the filtering upon the loggers using twoLoggerMatchFilterrules.The last
DenyAllFilterfilter in below configuration ensures that anything that doesn't match the expected logger names doesn't appear in the output.