Search code examples
azure-service-fabric

Log4net custom config files deployment with Azure Serivce Fabric


I want to configure log4net from xml file. I placed this file in root folder of the service. Property Copy to Output Directory is set to Copy Always and works fine — the file is getting copied.

Problem starts when I try to load this file with log4net.Config.XmlConfigurator.ConfigureAndWatch — it is not in the working directory, but in another directory with code.

I don't want to place configuration for log4net into app.config. It just doesn't work right now and I will spend lot of time on figuring this out.

Is there a way to add to a particular service some metadata(in files) and then access them?

Is there a way to do it in general and place files not in the root directory? For example, if I would want to have access to some binary data that cannot be placed in Settings.xml, how could I achieve this?

UPDATE

Looks like the only thing that needs to be done to copy files is to set their property to Copy Always. So, my real issues is that I have C:\SfDevCluster\[..]\work as working directory and not the directory with actual binaries.


Solution

  • You can use a custom configuration package or data package for this. Access the files using the ServiceContext object.

    More info here