Howiecamp
Howiecamp

Reputation: 3111

Unable to generate log NLog internal logging file on Azure App Service

I run websites and webjobs on Azure App Service and I want to enable NLog internal debugging to troubleshoot some logging problems. In my NLog configuration code I do:

InternalLogger.LogLevel = LogLevel.Trace;
InternalLogger.LogFile = "nlog.txt";

When run locally during development, nlog.txt shows up in the application binary directory (bin). On Azure it does not show up. Assuming perhaps a file system permissions issue I changed the code to:

InternalLogger.LogLevel = LogLevel.Trace;
InternalLogger.LogFile = @"d:\logfiles\nlog.txt";

Azure App Service guarantees that the d:\logfiles\ directory is writable. Yet still no nlog.txt file.

Ideas?

Upvotes: 5

Views: 3742

Answers (1)

Ivan Glasenberg
Ivan Glasenberg

Reputation: 29985

Actually the LogFiles folder is under D:\home in Azure (you mentioned the file path is d:\logfiles\, so I also tried to create a LogFiles folder under D: drive directly, but an 500 internal server error occurs).

Please try to change the value to d:\home\LogFiles\nlog.txt for InternalLogger.LogFile, like InternalLogger.LogFile= @"d:\home\LogFiles\nlog.txt" .

I can see the nlog.txt generated in azure by using the following code:

 InternalLogger.LogLevel = LogLevel.Trace;
 InternalLogger.LogFile = @"d:\home\LogFiles\nlog.txt";
 InternalLogger.Log(LogLevel.Trace, "a text message from here....");

You can refer to the pic below for test result.

enter image description here

Upvotes: 7

Related Questions