Search code examples
loggingazureazure-web-rolesnlogwindows-server-2012

Creating directory for NLog log file on Azure


I'm writting application, which is running as WebRole on IIS. I'm using NLog for logging. One of NLog target is file.

I need this file with all recent events. Of course I have other targets, which let me easier access all log data I need. I have a problem with file target.

On my local PC, when I configure NLog to log to C:\somedir1\somedir2\somedir3\logfile NLog creates all needed dirs and log file. In Azure I need to manually create directories and change permission before NLog can write to logfile.

Is there any way to add some kind of task to project which would create all dirs I need? I think user on which WebRole is running has not enough permissions to create dir in C: drive.


Solution

  • You can add StartupTask to your webrole and run it with elevated privileges.

    http://msdn.microsoft.com/en-us/library/windowsazure/gg456327.aspx