Can't write log to LogEntries from Azure Web App

From within App.Net Web Api (version 5) I am trying to send logs to LogEntries but cannot. With the same code and configuration, I can successfully send logs from localhost.

This is the code I am using to send the logs (using NLog :)

private static Logger log = LogManager.GetCurrentClassLogger();

public static void LogString(string message)
{
    log.Error(builder.ToString());
}

      

This is the web.config configuration:

<appSettings>
    <add key="Logentries.Token" value="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" />
</appSettings>

<nlog>
<extensions>
  <add assembly="LogentriesNLog" />
</extensions>
<targets>
  <target name="logentries" type="Logentries" debug="true" httpPut="false" ssl="false" layout="${date:format=ddd MMM dd} ${time:format=HH:mm:ss} ${date:format=zzz yyyy} ${logger} : ${LEVEL}, ${message}" />
</targets>
<rules>
  <logger name="*" minLevel="Debug" appendTo="logentries" />
</rules>

      

When I run this code for production as an Azure Web App, I don't see any logs in the LogEntries console. When I run it on localhost it succeeds.

I also tried making a simple HTTP request with WebRequest class to google.com and could get 200 from server to Azure. So I think the Azure app can access the internet, but for some reason cannot / cannot access the LogEntries servers.

How can I diagnose this?

+3


source to share


2 answers


If you are on Azure WebSite, there is no standard system EventLog. So this might be the problem you are having with not being able to apply the logs.



Below is a detailed overview of all the options available on Azure Sites.

0


source


Sorry this is a little out of date, but perhaps for future readers. I had the following problems getting LogEntries working with Azure Webapps. 1) The document is in error regarding the order of the configuration settings; it only reads the Azure portal settings and application settings after it has checked its own configuration. So if you have a token on the target line, it will use that and ignore appsetting. 2) LogentriesCore and LogentriesNlog must be in the application folder and not in the NLog.dll location. I noticed this because I was using logging from a shared library and I had to add links to LogentriesCore and LogentriesNLog to projects using the library, although they shouldn't care.



To diagnose problems, I did this 1) Set up tracing in the webapp (to go to the Blob store in our case). Just use Trace.Writeline and set up the trace in the Azure portal. 2) When creating my Logger, I first enable exceptions: LogManager.ThrowExceptions = true; Logger = LogManager.GetCurrentClassLogger (); 3) Enable debugging on the target line of Logentries in config:     

0


source







All Articles