1

I'm just trying to ship some error logs from my ASP.NET MVC 5 app to Logz.io

I'm using NLog to ship my logs.
I've installed NLog and NLog.Web packages

I have the following nlog.config file :

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            autoReload="true"
            throwExceptions="true"
            internalLogLevel="ERROR"
            internalLogFile="C:\Temp\nlog-internal.log">

  <extensions>
    <add assembly="Logzio.DotNet.NLog"/>
  </extensions>

  <targets async="true">
    <target name="file" type="File"
            fileName="<pathToFileName>"
            archiveFileName="<pathToArchiveFileName>"
            keepFileOpen="false"
            layout="<long layout patten>"/>

    <target name="logzio"
                    type="Logzio"
                    token="LRK......"
                    logzioType="nlog"
                    listenerUrl="https://listener.logz.io:8071"
                    bufferSize="1"
                    bufferTimeout="00:00:05"
                    retriesMaxAttempts="3"
                    retriesInterval="00:00:02"
                    debug="false" />
  </targets>
  <rules>
    <logger name="*" minlevel="Debug" writeTo="logzio" />
  </rules>
</nlog>

Then, each of my C# controller have this line :

private static Logger logger = LogManager.GetCurrentClassLogger();

and then I try to ship my logs using something like :

logger.Fatal("Something bad happens");

However, when I writeTo="file" in the nlog.config file, I can find a log file on my local disk with "Something bad happens", so everything is fine.

However, nothing appear on my LogzIo web interface when I writeTo="logzio", no logs are shipped there.

What did I miss ?

user2687153
  • 427
  • 5
  • 24
  • Have you tried to change to `internalLogLevel="Warn"` and look in the `internalLogFile` ? – Rolf Kristensen Dec 03 '18 at 13:35
  • I uninstall / reinstall the LogzIo package (mine were outdated) and when I `writeTo="file"` in my localhost environment, I now have this Error 3 times (like the 3 retriesMaxAttempts) : `Error : System.Net.WebException : The request was aborted: Could not create SSL/TLS secure channel`. I'm investigating but any clue is appreciated :) – user2687153 Dec 04 '18 at 10:49
  • Maybe force enable strong crypto: https://support.microsoft.com/help/4458166/ – Rolf Kristensen Dec 04 '18 at 14:22

2 Answers2

1

Answering my own question after I found how to solve this.

Actually, my whole project use HTTPS. In internal Nlog logs, I had this error

Error : System.Net.WebException : The request was aborted: Could not create SSL/TLS secure channel

I've just added this line of code at the very beginning of ApplicationStart in Global.asax.cs

ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;

After testing the whole project during some days, it seems it doesn't affect the other parts of the project. However, just be careful as it is a global setting

user2687153
  • 427
  • 5
  • 24
0

I had the same issue, and it turned out that in my published app the logzio dlls were missing. I added them and it resolved the issue.

Check if you're missing these files in your bin folder: Logzio.DotNet.NLog.dll Logzio.DotNet.Core.dll

Zaf
  • 91
  • 1
  • 5