1

I havent found info in how to log something in the azure logs, I suppose sdk should allow this, if its possible can you provide a small example or link?>

Luis Valencia
  • 32,619
  • 93
  • 286
  • 506
  • Possible duplicate of [How do I write to the logs in Azure WebJobs from a C# console app?](http://stackoverflow.com/questions/22417081/how-do-i-write-to-the-logs-in-azure-webjobs-from-a-c-sharp-console-app) – Michael Freidgeim Jul 12 '16 at 06:52

2 Answers2

3

If you are using the WebJobs SDK then we redirect the standard output stream so if you write to console it should also write to logs.

Example:

Console.WriteLine("Log message");
Victor Hurdugaci
  • 28,177
  • 5
  • 87
  • 103
  • 1
    You don't have to use the SDK to get logs, any output to console will get logged. – Amit Apple Apr 11 '14 at 05:43
  • If `Console.Write` gets logged to the Azure WebJob logs, then why would we include a TextWriter parameter in a method declaration like many of the samples show? – Dan Friedman Nov 30 '16 at 06:16
  • Because you can have multiple jobs running simultaneously. Without it, the dashboard could not separate the messages from parallel runs easily. – Victor Hurdugaci Nov 30 '16 at 19:20
2

I've not tried this yet but I would think it should be possible to get NLog working in a WebJob.

I could imagine two log targets being configured, one of type ColoredConsole and another of type File. ColoredConsole runs in debug and release mode (when deployed to Azure) and any messages would be directed to log output and viewable in Kudu. The File target could be turned off in Release mode but available when running locally in development.

NLog loggers can be turned off by setting minLevel="Off" in a .config transform file.

Stuart Hallows
  • 8,795
  • 5
  • 45
  • 57