I am trying to use another logger than the standard Tracewriter
in Azure function. Mostly NLog which all works locally when running the Azure Function but nothing gets written after I deployed to Azure.
Load config through blob. I store my config file in the storage blob and loads it in as a parameter
[FunctionName("Update")]
public static IActionResult Run([HttpTrigger(AuthorizationLevel.Function, "put", Route = null)]HttpRequest req,
[Blob("nlog/nlog.config", FileAccess.Read)] string inputBlob)
Logger.LoadConfiguration(inputBlob);
Logger.Info("This does not show in Azure");
...
My logger class where i load the configuration
public class Logger
{
public static Logger Log = LogManager.GetCurrentClassLogger();
private static bool _isConfigrued;
public static void LoadConfiguration(string xmlString)
{
if (string.IsNullOrEmpty(xmlString))
return;
if (!_isConfigrued)
{
StringReader sr = new StringReader(xmlString);
XmlReader xr = XmlReader.Create(sr);
LogManager.Configuration = new XmlLoggingConfiguration(xr, null);
Log = LogManager.GetCurrentClassLogger();
_isConfigrued = true;
}
}
}
I then configure the the NLog to write to trace
<targets>
<target name='console' type='Console' layout='Console ${message}' />
<target name="trace" xsi:type="Trace" layout="Trace ${message}" />
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="trace" />
<logger name="*" minlevel="Trace" writeTo="console" />
</rules>
But nothing gets written to trace/console
I also tried loading the config like suggested here
https://blogs.msdn.microsoft.com/waws/2017/03/16/nlog-and-database/
No luck either
I also tried the Microsoft.Extentions.Loggin.Ilogger
, works locally but nothing gets printed on Azure.
No exceptions are thrown just and empty console window.