Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to configure "Analogy.LogViewer.Serilog.Sinks"? #308

Open
afluegge opened this issue Sep 1, 2021 · 7 comments
Open

How to configure "Analogy.LogViewer.Serilog.Sinks"? #308

afluegge opened this issue Sep 1, 2021 · 7 comments

Comments

@afluegge
Copy link

afluegge commented Sep 1, 2021

Hi Lior,

I tried to use the log viewer with the self hosted gRPC server together with the Serilog sink. I am not able to get it to work.
I have a .NET5 WPF application and I configure my Serilog sinks from the appsettings.json file. For both "Console" and "Debug" sinks everything works fine. However, I am not able to get the "Analogy.LogViewer.Serilog.Sinks" sink to work. I was not able to find any documentation that describes how to setup the sink correctly so that I can see log entries in your log viewer app.

Can you please provide me some guidance on how to setup the following configuration:

  • Analogy Log Viewer 4.7.5.0 installed and running
    • gRPC Self Hosting Server is started
  • "AnalogyLogServerSink" package is added to application

What is the correct syntax to configure the sink from appsettings.json? This is my try:

    "Serilog": {
        "WriteTo": [
            {
                "Name": "Debug",
                "Args": {
                    "outputTemplate": "[{Timestamp:HH:mm:ss.fff} {Level:u}][{SourceContext}] {Message:lj}{NewLine}{Exception}"
                }
            },
            {
                "Name": "AnalogyLogServerSink",
                "Args": {
                    "outputTemplate": "[{Timestamp:HH:mm:ss.fff} {Level:u}][{SourceContext}] {Message:lj}{NewLine}{Exception}"
                }
            },
            {
                "Name": "Console",
                "Args": {
                    "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} {MachineName} {EnvironmentUserName} [{Level:u4}] <{ThreadId}> [{SourceContext:l}] {Message:lj}{NewLine}{Exception}"
                },
                "theme": "AnsiConsoleTheme.Literate"
            }
        ],
        "Enrich": [
            "FromLogContext",
            "WithMachineName",
            "WithThreadId",
            "WithEnvironmentUserName",
            "WithCorrelationId"
        ],
        "MinimumLevel": {
            "Default": "Verbose"
        }
    }
@LiorBanai
Copy link
Member

LiorBanai commented Sep 1, 2021

Hi @afluegge ,
I'll create demo application and instruction how to use it this weekend :)
I have not tested it for some time (I using other extensions like https://github.com/Analogy-LogViewer/Analogy.AspNetCore.LogProvider) so it is possible something might be broken.

Will update you :)

for now you of course can open Serilog logs directly

@LiorBanai
Copy link
Member

one quick check, are you using the gRPC Receiver tab?
image

@LiorBanai
Copy link
Member

yeah the self hosted does not receive the messages. Will update (the Analogy Server (https://github.com/Analogy-LogViewer/Real-Time-Log-Server) works ok)

@LiorBanai
Copy link
Member

found the issue (hard coded port 7000) . Once I corrected it the self hosted got messages.
I'll update you once everything is fixed :)
Analogy-LogViewer/Analogy.LogViewer.gRPC#137

@LiorBanai
Copy link
Member

related issue: [Analogy.LogViewer.Serilog.Sinks] Sink is using port 6000 without ability to change address #309

@afluegge
Copy link
Author

afluegge commented Sep 1, 2021

Could you also please provide documentation on how to configure the serilog sink via appsettings.json?

@LiorBanai
Copy link
Member

I have released new version of Analogy with the removal of the hard coded ports. I tested it and it works.
to use open the self hosted settings and set your desired port:
image

to use the sink:

            var log = new LoggerConfiguration()
                .WriteTo.AnalogyLogServerSink("http://localhost:7000").CreateLogger();
            for (int i = 0; i < 1000; i++)
            {
                log.Information("test {i}", i);
                await Task.Delay(250);
            }

I'm still trying to figure up how to set it in the appsettings.json. no luck for now

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

No branches or pull requests

2 participants