Skip to content

Conversation

nblumhardt
Copy link
Member

@cilerler
Copy link

cilerler commented Nov 16, 2016

Following code

using (Logger.BeginScope("Some name"))
using (Logger.BeginScope(42))
using (Logger.BeginScope("Formatted {WithValue}", 12345))
using (Logger.BeginScope(new Dictionary<string, object> { ["ViaDictionary"] = 100 }))

ends up as

image

and not like this

image

as stated in here for Scope item

I saw that while testing the following code

using (Logger.BeginScope("Scoping {CommandName} {Reference}", GetType().Name, Guid.NewGuid()))

@nblumhardt
Copy link
Member Author

@cilerler thanks for checking it out. I've just installed the latest -pre:

    "Serilog.Extensions.Logging": "1.3.0-dev-10129",
    "Serilog.Sinks.Seq": "3.1.1"

With the following in Startup.cs:

            loggerFactory.AddSerilog(new LoggerConfiguration()
                .WriteTo.Seq("http://localhost:5341")
                .CreateLogger());

And the following in HomeController.cs:

    public class HomeController : Controller
    {
        ILogger<HomeController> Logger;

        public HomeController(ILogger<HomeController> logger)
        {
            Logger = logger;
        }

        public IActionResult Index()
        {
            using (Logger.BeginScope("Some name"))
            using (Logger.BeginScope(42))
            using (Logger.BeginScope("Formatted {WithValue}", 12345))
            using (Logger.BeginScope(new Dictionary<string, object> { ["ViaDictionary"] = 100 }))
            {
                Logger.LogInformation("In");
            }

            return View();
        }

Result in Seq:

image

Can you spot any differences with the setup you're using?

@cilerler
Copy link

cilerler commented Nov 16, 2016

project.json

"Seq.Extensions.Logging": "2.1.0-dev-00022",

Startup.cs

public void Configure(ILoggerFactory loggerFactory)
{
    loggerFactory.AddConsole(Configuration.GetSection("Logging"));
    loggerFactory.AddDebug();
    loggerFactory.AddSeq(Configuration.GetSection("Seq"));
}

I do use Console application which shouldn't response differently but wanted to mention anyway.

@nblumhardt
Copy link
Member Author

Aha :-) that would be this project.

If you change the version of the package to 2.1.1 you should get the output you're expecting.

Cheers!

@cilerler
Copy link

Sorry about that, changed it and confirming that it is working like a charm. Thanks again! 😎

@merbla
Copy link
Contributor

merbla commented Nov 16, 2016

@merbla
Copy link
Contributor

merbla commented Nov 16, 2016

And possibly v2.3.0 of Serilog?

@nblumhardt
Copy link
Member Author

@merbla keen to push the version of the Serilog dependency forwards; I think it might be a bit early to cut off support for the 1.0 version of MEL, though - may be some apps that can't move forward yet.

Perhaps we bump both versions up in dev and do that in the next point release?

@nblumhardt nblumhardt merged commit 40ae58e into master Nov 16, 2016
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

Successfully merging this pull request may close these issues.

4 participants