Skip to content
This repository has been archived by the owner on Mar 1, 2022. It is now read-only.

Sink not working #39

Open
Nerkyator opened this issue Jun 18, 2018 · 17 comments
Open

Sink not working #39

Nerkyator opened this issue Jun 18, 2018 · 17 comments

Comments

@Nerkyator
Copy link

Nerkyator commented Jun 18, 2018

Just tried this sink with a working Loggly account but seems not working at all.
This is my configuration code:

        private void SetupLogglyConfiguration()
        {
            const string appName = "APP-NAME";
            const string customerToken = "MY-TOKEN";

            //Configure Loggly
            var config = LogglyConfig.Instance;
            config.CustomerToken = customerToken;
            config.ApplicationName = appName;
            config.Transport = new TransportConfiguration()
            {
                EndpointHostname = "XXXXX.loggly.com",
                EndpointPort = 443,
                LogTransport = LogTransport.Https
            };
            config.ThrowExceptions = true;
            config.

            //Tags
            config.TagConfig.Tags.AddRange(new ITag[]{
                new ApplicationNameTag {Formatter = "application-{0}"},
                new HostnameTag { Formatter = "host-{0}" }
            });
        }

After launch above method I create my log like this:

new LoggerConfiguration().Enrich.With(new UserLogEventEnricher(userName, $"v. {appVersionString} b{appBuildNumber}")).WriteTo.Loggly(bufferBaseFilename: @"log_buffer").CreateLogger();

But when I log something nothing appears on website side. Worst problem is that there are no error or exception at all. I tried to place a wrong token or a wrong connection port (433888888 is a little bit large number for a port) but I get no error, it does nothing at all.
What am I missing?

Edit:
Checked on app folder (in simulator) I can see the log_buffer file is created and filled with logs so the problem seems only the connection with Loggly server.

@raidevnet
Copy link

Have the same issue, buffer file contains messages but nothing goes to Loggly. I'm on .NET Core 2.1

@facundofarias
Copy link

Hi there,

We are having the same issue. Any ideas?

@MiguelAlho
Copy link
Contributor

Hi. Sorry for being so late to respond on this. Can you try to activate the Serilog's SelfLog to see if any erro rinfo from within Serilog appears?

https://github.com/serilog/serilog/wiki/Debugging-and-Diagnostics

@nicholasyin
Copy link

Having the same issue. Simply not working. Waste of time.

@MiguelAlho
Copy link
Contributor

hi @nicholasyin . Have you tried activating Serilog's selflog functionality to see if any error is being generated?

@nicholasyin
Copy link

hi @nicholasyin . Have you tried activating Serilog's selflog functionality to see if any error is being generated?

Thanks, but no, i simply quit using loggly.

@chrissychimi
Copy link

I don't know that this will be particularly helpful, but we were successfully using this sink for years, then upgraded to dotnet core 2.1 and it suddenly stopped working (other serilog sinks continued to work without a problem). Reverting back to 2.0 fixed the issue, but we are still looking into this as we want to move to 2.1.

I tried using SelfLog but wasn't able to get it to write to a file. Writing to the console, I occasionally saw this message: "Received failed HTTP shipping result Unknown:".

One of our developers noted that dotnet changed their sockets api in 2.1; perhaps that could be part of the problem? (https://docs.microsoft.com/en-us/dotnet/core/whats-new/dotnet-core-2-1#sockets-improvements)

@MiguelAlho
Copy link
Contributor

Thanks @chrissychimi . The package that is generated targets netstandard 1.5 so it should be compatible, but maybe the ´System.Net.Http´ ref could be a problem (or a problem in the loggly-csharp depdendency)? The sample project could probably be used to run a quick test on that.

If you or your team gets a chance, could you check to see it the problem persists in the 5.4.0-dev package? (https://www.nuget.org/packages/Serilog.Sinks.Loggly/5.4.0-dev-00175);

I haven't upgraded any of our apps that use this to 2.1, so I haven't seen that behaviour yet, but my team has been using the dev package for about a month without any visible problems.

@chriswolf-nrg
Copy link

chriswolf-nrg commented Jan 15, 2019

Hi @MiguelAlho I tried using 5.4.0-dev-00175 and that didn't help. The only thing that works with TargetFrameWork==netcoreapp2.1 is the sample durable logger:
https://github.com/serilog/serilog-sinks-loggly/tree/dev/sample/sampleDurableLogger

I got the following code to work by using the same NuGet package versions as the sampleDurableLogger. The remaining issue is that, in our production code, we prefer to configure Serilog via the appsettings.json, which worked fine with netcoreapp2.0 but doesn't send to Loggly with netcoreapp2.1.

           var config = LogglyConfig.Instance;
            config.CustomerToken = "xxxxxxxx-xxxxxx-xxxxxx-xxxxx";
            config.ApplicationName = "ConsoleApp4";
            config.Transport = new TransportConfiguration()
            {
                EndpointHostname = "logs-01.loggly.com",
                EndpointPort = 443,
                LogTransport = LogTransport.Https
            };
            config.ThrowExceptions = true;
            config.TagConfig.Tags.Add(new ApplicationNameTag { Formatter = "cwolf" });
            config.TagConfig.Tags.Add(new ApplicationNameTag { Formatter = "ConsoleApp4" });

            var logger = new LoggerConfiguration()
                .MinimumLevel.Debug()
                .Enrich.FromLogContext()
                .Enrich.WithThreadId()
                .WriteTo.Loggly(bufferBaseFilename: @"log_buffer")
                .CreateLogger();

            logger.Error("Test789");

Any other ideas?

@chriswolf-nrg
Copy link

This is the configuration as configured via appettings.json - compared with programmatic configuration, which works, is anything missing that would cause the Serilog Sink to not send to Loggly?

  Name Value Type
[33] {[Serilog:Enrich:0, FromLogContext]} System.Collections.Generic.KeyValuePair<string, string>
[34] {[Serilog:Enrich:1, WithExceptionDetails]} System.Collections.Generic.KeyValuePair<string, string>
[35] {[Serilog:Enrich:2, WithThreadId]} System.Collections.Generic.KeyValuePair<string, string>
[36] {[Serilog:MinimumLevel:Default, Verbose]} System.Collections.Generic.KeyValuePair<string, string>
[37] {[Serilog:MinimumLevel:Override:Microsoft, Warning]} System.Collections.Generic.KeyValuePair<string, string>
[38] {[Serilog:MinimumLevel:Override:System, Warning]} System.Collections.Generic.KeyValuePair<string, string>
[39] {[Serilog:Properties:Application, PortalWorker]} System.Collections.Generic.KeyValuePair<string, string>
[40] {[Serilog:Properties:Environment, cwolf]} System.Collections.Generic.KeyValuePair<string, string>
[41] {[Serilog:Using:0, Serilog.Sinks.Loggly]} System.Collections.Generic.KeyValuePair<string, string>
[42] {[Serilog:WriteTo:0:Args:bufferBaseFilename, c:\temp\log_buffer]} System.Collections.Generic.KeyValuePair<string, string>
[43] {[Serilog:WriteTo:0:Name, Loggly]} System.Collections.Generic.KeyValuePair<string, string>

@chriswolf-nrg
Copy link

I am trying to debug the sink code myself, but it's not stopping in the breakpoints I set in LoggerConfigurationLogglyExtensions - likely due to:
https://github.com/MicrosoftDocs/visualstudio-docs/issues/2003

@MiguelAlho
Copy link
Contributor

@chriswolf-nrg I ran a few tests with the sample app (as-is) with my token and I can see the messages in Loggly's Live Tail feature appearing. I had to use the app token (I have one i use for non-prod apps) since the one supplied in the Live Tail Tokens tab did not work.

The messages did appear, though with some significant delay in the live tail page. I tested for netcoreapp1.0, netcoreapp2.0, netcoreapp2.1 and netcoreapp2.2. I DID have to make a small change to the Sample App's .csprojfile be able to debug the app in visual studio - I added a RuntimeIdentifier element so that VS code find and call the .exe:

<RuntimeIdentifier>win10-x64</RuntimeIdentifier>

I noticed in the configuration snippet above that you added two ApplicaitonNameTag tags. is that possible in Loggly? (I have only used one and never tried two of that type).

The config via AppSettings i believe is recent. There initially were some issues with configuring sinks that required a deeper config tree; That might be something worth looking into (either by flattening the options or some other approach).

@chriswolf-nrg
Copy link

Hi @MiguelAlho - thanks for testing it out. When I test, I use http://www.charlesproxy.com so when it captures out going REST messages, then I know the Loggly Sink is working, regardless of the delay.

Unfortunately, I think the config via AppSettings is very limited and barely works except for the simplest use cases. For example, here is my appsettings.json:

  "Serilog": {
    "Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.Loggly" ],
    "WriteTo": [
      {
        "Name": "Console",
        "Args": {
          "theme": "Serilog.Sinks.SystemConsole.Themes.ConsoleTheme.None"
        }
      },
      {
        "Name": "Loggly",
        "Args": {
          "tags": "cwolf",
          "customerToken": "999f30b7-1234-5678-8804-999d654a3999",
          "endpointHostName": "logs-00.loggly.com",
          "isEnabled": "false"
        }
      }
    ],
    "Enrich": [ "FromLogContext", "WithExceptionDetails", "WithThreadId" ],
    "Properties": {
      "Application": "PortalWorker",
      "Environment": "cwolf"
    }
  }

In the above example, trying to set the theme on the Console Sink doesn't work - I get a cast exception; the Loggly sink doesn't throw an exception, but it never sends anything to Loggly.

@chriswolf-nrg
Copy link

chriswolf-nrg commented Jan 18, 2019

@MiguelAlho to answer your question about the code snippet setting tags:

 config.TagConfig.Tags.Add(new ApplicationNameTag { Formatter = "cwolf" });
 config.TagConfig.Tags.Add(new ApplicationNameTag { Formatter = "ConsoleApp4" });

Here's what the output looks like:
loggly_sample

Again, this is with the programmatic configuration - the AppSettings approach doesn't work at all.

@CDargis
Copy link

CDargis commented Mar 21, 2019

Any activity on this? Not being able to use app settings to configure the sink is kind of a deal breaker.

@MiguelAlho
Copy link
Contributor

The Loggly-Csharp library seems to have gotten an update / fix related to NetStandard 1.5. :

neutmute/loggly-csharp@7eb51d2:

Would this help in any way? This issue is obviously old, and maybe no longer relevant, but still worth adding the note here.

@MiguelAlho
Copy link
Contributor

The features/jsonConfig branch contains a new, sample project to validate and test out appsetting.json based configurations. Only tested for NetCore 3.1, for now.

#53

@chriswolf-nrg I based the configuraton in the sample off of yours. Do note that your "isEnabled": "false" might not allow messages to get to loggly

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants