Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Provide an implementation of ILogger from Microsoft.Extensions.Logging #175

Closed
LordMike opened this issue Feb 3, 2017 · 5 comments
Closed

Comments

@LordMike
Copy link

LordMike commented Feb 3, 2017

Building on my comment on #125, support for .NET Core, an implementation that fits in Microsoft.Extensions.Logging should be provided. I have created my own project for it, copied the same buildup as from the Debug logger, and called it Microsoft.Extensions.Logging.Raven, for which I've attached the relevant source code.

Feel free to use the attached as a base to build an "official" log provider for the MS log framework. :)

In the end, the code can be used like this:

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
	loggerFactory.AddConsole(Configuration.GetSection("Logging"));
	loggerFactory.AddRavenLogger(app.ApplicationServices.GetRequiredService<IRavenClient>(), LogLevel.Error);
	loggerFactory.AddDebug();

	// .. snip
}

Microsoft.Extensions.Logging.Raven.zip

@asbjornu
Copy link
Contributor

asbjornu commented Mar 5, 2018

I would happily accept a pull request with this in it. Now that we have a .NET Core build, it shouldn't be too much work getting it in.

@roryprimrose
Copy link

I just blogged about this the other day - https://www.neovolve.com/2018/06/07/ilogger-for-sentry/

That might meet your needs.

@bruno-garcia
Copy link
Member

Hi @roryprimrose ! Thank you for creating this integration over raven-csharp. With over 300.000 downloads, there were lots of requests for this.

I'd like to mention that Sentry is working on unifying the API across the SDKs to help with developer experience and also maintenance/documentation. As part of this API unification we're designing it in a way where integrations can work together in order to augment the event data (aka: context).

In the case of the .NET SDK, the first integrations we're considering due to demand are ASP.NET Core and Microsoft.Extensions.Logging. The goal is to not only easily integrate with the frameworks but also use the Logging messages as scope data (i.e: breadcrumbs/tags/extra, etc) in the case of events sent either manually through the client or through the middleware integration. Any scope data set manually will also be included in events sent from any source, including a LogError call.

The code is on its own repo: sentry-dotnet. I'd love to get some feedback.

@bruno-garcia
Copy link
Member

We've just released the first preview of the ASP.NET Core integration.

It also brings in the Microsoft.Extensions.Logging so that your Informational log messages in the same transaction are sent as breadcrumbs.

It's possible to use only the Microsoft.Extensions.Logging, without the ASP.NET Core integration.
There's a sample of it here

I would love to get some feedback as we work toward a point release:

It's on NuGet:

Logging integration: https://www.nuget.org/packages/Sentry.Extensions.Logging/
ASP.NET Core integration: https://www.nuget.org/packages/Sentry.AspNetCore/
Main SDK (client, etc): https://www.nuget.org/packages/Sentry/

Release on GitHub:
https://github.com/getsentry/sentry-dotnet/releases

Docs:
https://github.com/getsentry/sentry-dotnet/

I'm online on Gitter: https://gitter.im/getsentry/dotnet

@bruno-garcia
Copy link
Member

We've released the new SDK which solves this issue:

https://github.com/getsentry/sentry-dotnet/releases

https://www.nuget.org/packages/Sentry

I'll close this issue but please feel free to reopen or open one in the new repository if you have any issues integrating. We'll be happy to help you moving over to the new SDK.

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

4 participants