After introducing Elmah error logging to a web site, you could be confronted by the need to set permissions on the log output folder during deployment. You can avoid the permissions problem by directing the log output to the App_Data folder in your site directory as long as you have an App_Data folder. This is because the permissions are automatically set for App_Data when deploying with MSDeploy.
Let’s say that you want the logs to be placed in another folder such as Elmah or Logs, then you do need to give write permissions to the application pool that your site is running under.
You could just script the folder permissions and it would not be too hard, but what if you wanted to have it done as part of the deployment process. I discovered a customization that does this. It is based on the same process to set permissions as App_Data. It involves adding an MSBuild project and configuration and it is explained in detail by Sayed Ibrahim Hashimi.