1

Thanks in advance.

I want to use Nlog in Azure function V1,I have added Nlog and config file.I can see the ilogger object getting created, but that is not writing to console:(

Only tracewriter provided by Azure function alone working in console log.

Rolf Kristensen
  • 17,785
  • 1
  • 51
  • 70
ReegsG
  • 31
  • 4
  • Good idea to include the contents of the Nlog.config that you are using. Along with the code for setting up logging in the Azure Function. – Rolf Kristensen Jun 03 '20 at 19:46
  • Duplicate of: https://stackoverflow.com/questions/35058029/how-to-integrate-nlog-to-write-log-to-azure-streaming-log ? – Rolf Kristensen Jun 03 '20 at 19:58
  • Hi, I tried that option as well...it's not duplicate....the object is created but not writing to the console in v1 Azure – ReegsG Jun 05 '20 at 01:21
  • What do you mean by "the object is created" ? Can you update your question with the NLog.config that you trying to use? If NLog.config is not loaded properly then no output is created. – Rolf Kristensen Jun 05 '20 at 06:41

1 Answers1

0

Have never tried deploying an Azure Function, but many seems to have issues with deploying NLog.config (or other resource/config-files).

Maybe try putting the NLog-configuration into appsetting.json (Requires explicit load of NLogLoggingConfiguration) :

https://github.com/NLog/NLog.Extensions.Logging/wiki/Json-NLog-Config

The NLog Trace Target (with rawWrite=true) should support Azure Streaming Log.

See also: https://github.com/NLog/NLog.Extensions.Logging/wiki/NLog-cloud-logging-with-Azure-function-or-AWS-lambda

Rolf Kristensen
  • 17,785
  • 1
  • 51
  • 70
  • Hi ,I have tried both the option you mentioned, the object is created, but when I used to write to console using .info or .error it failed to write in console for azure v1 – ReegsG Jun 05 '20 at 01:20
  • @ReegsG What do you mean by "the object is created?" Have you tried using to both Console-Target and Trace-Target at the same time? If NLog.config is not loaded properly then no output is created – Rolf Kristensen Jun 05 '20 at 06:43
  • Hi, Object created mean, I can see ilogger instance created with Nlog config or creating config via code.but while writing to console it's not writing. – ReegsG Jun 08 '20 at 17:17
  • @ReegsG If your Azure Function doesn't load the NLog-config, then you will not get any output. Have you tried to configure NLog by code, and use the NLog Target to write to the tracewriter provided by Azure function. See https://www.nuget.org/packages/NLog.Targets.TextWriter – Rolf Kristensen Jun 08 '20 at 18:23
  • Hi ,Just I mentioned before.Nlogconfig loaded and instance of the object is created...but log not writing to console.even I tried to using code without config ...again log instance created but not writing to console.im using azure function v1...yes tried that as well..but same issue – ReegsG Jun 09 '20 at 04:21