0

I have 12 projects in my solution file. There are most Windows services (ServiceProj_1, ServiceProj_2, ...) and one project is of web application (WebApp). I use log4net for logging. WebApp and ServiceProject_1, ServiceProj_2, ... have log4net configuration into web.config and app.config files respectively. We have implemented a DMZ, so the WebApp is only exposed to the other people. Now there is a requirement to use logging of those windows service projects instead of WebApp.

I have come to know that I can create a custom appender and make it possible. The catch is, there are lots of lines already written into WebApp to log a LogMessage into log file so we cannot touch those lines.

I have no idea what to do and how to do. Need help. If the description is not understandable then please let me know I will try to explain more.

Ry-
  • 218,210
  • 55
  • 464
  • 476
darthVader
  • 197
  • 4
  • 17
  • 1
    I edited your question, take a look. It is unclear `at least` to me what you are saying. I am not sure what your end result needs to be? – panoskarajohn Dec 19 '19 at 11:02

1 Answers1

0

You can specify the config file and load it dynamically... Here my config file is found at the location of FullConfigFilePath.

private Configuration Config
{
    get
    {
        if (_Config != null) return _Config;

        _Config = ConfigurationManager.OpenMappedExeConfiguration(
        new ExeConfigurationFileMap()
        {
            ExeConfigFilename = FullConfigFilePath
        }, ConfigurationUserLevel.None);
        return _Config;
    }
}   

Once the config is loaded you can access the values from there.... For instance.....

private string BaseUrl
{
    get
    {
        return this.Config.AppSettings.Settings["MyConfigSetting"].Value;
    }
}

Hopefully you can tweak and use this sort of approach for your needs.

AntDC
  • 1,807
  • 14
  • 23