Reputation: 212
I have a pretty standard cloud service (1 web role + 1 worker role). I am using log4net as the logging framework and it's working fine. One of the advantages of log4net is that you can change the configuration on the fly. e.g. change the logging level from Info to Debug. But that relies on you updating the logging config file on the server - something you can't do in a cloud service.
Has anyone tackled this? Is there a way, a technique, a best practice for setting up your log4net config in such a way that you can update it on the fly without having to redeploy the whole package?
Upvotes: 0
Views: 498
Reputation: 3800
Quick answer is you can RDP to the instance(s) and change the config files there. Though that is not long term solution for you.
If your instance has to be taken down by azure to do an update on the OS, you will lose those changes in the config due to the instance being restored using the uploaded package you created originally (pre RDP and config modifications). This is one huge scenario that is a lot easier in Web Apps.
For log4net I've seen a couple approaches (though I haven't personally implemented either):
Both require you to more or less write some code that will dynamically configure log4net at runtime. If you do a search for "Changing log4net config dynamically" you should find something that is close to what you would need to do.
Upvotes: 1
Reputation: 1165
You could use the Cloud Explorer in Visual Studio 2015 to remotely edit the Web.config file of your Web App to change your log4net config.
Be aware that your changes will be overridden the next time you redeploy if you do not also commit your change upstream.
Upvotes: 0