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

AddRollbarProvider from ILoggingBuilder .Net Core #511

Open
mymys91 opened this issue Mar 27, 2020 · 8 comments
Open

AddRollbarProvider from ILoggingBuilder .Net Core #511

mymys91 opened this issue Mar 27, 2020 · 8 comments
Assignees
Labels
bug Denotes a runtime problem within the SDK question

Comments

@mymys91
Copy link

mymys91 commented Mar 27, 2020

Describe the bug
Hi, I am not sure this is a bug or not. When I try to add Rollbar provider in ConfigureLogging as same as I do with AddConsole(). It will create 2 LoggerFactory and lead to cannot log to Console anymore.
Expected behavior
I expect that default LoggerFactory will have 2 providers: console & rollbar.

To Reproduce

  1. Create a new project with template type Worker Service
  2. Add Rollbar accesstoken & Environment to appsetting.json
  3. AddRollbar as in below picture.

Screenshots
image

Rollbar Client - Rollbar.NET Hosting Environment (please complete the following information):

  • .NET flavor and its version: .NET Core 3.0
  • Rollbar.NET Version: 3.7.1

Additional context
From Rollbar sourecode, I see function ILoggingBuilder AddRollbar try add RollbarLoggerFactory, I do not understand its purpose.

@akornich akornich self-assigned this Mar 27, 2020
@akornich
Copy link
Contributor

@mymys91 , thanks for reporting the issue! I'll look into it probably early next week.

@Lechus
Copy link

Lechus commented Mar 30, 2020

confirm, Console logger is removed.

@Lechus
Copy link

Lechus commented Mar 30, 2020

I am using Rollbar.NetCore.AspNet project directly:
with stripped out depedency on HttpContextAncestor
and some other mods and this works, does not remove Console logger.

Any chance to have a Rollbar.NetCore package with :
RollbarServiceCollectionExtensions
public static IServiceCollection AddRollbarLogger(this IServiceCollection services){}
RollbarServiceCollectionExtensions - without dependency on Http?
I think the request is already on Issues.

@akornich
Copy link
Contributor

@Lechus , thanks for the feedback! I think I should be able to dedicate some time to these topics within the next couple of weeks.

@akornich akornich added the bug Denotes a runtime problem within the SDK label Mar 30, 2020
@mymys91
Copy link
Author

mymys91 commented Apr 1, 2020

Hello,
Today I try including libraries Rollbar & Rollbar.NetCore.AspNet source code for debugging another need that I want to log error while building host (ASPNETCore 3.1). However, the message didn't send to rollbar, what I can work around is make a Thread sleep 5s 💃

By the way, I comment the line register factory to check my reported issue. What I can see now that loggerfactory has 2 providers: rollbar & console --> they work well

image

@akornich
Copy link
Contributor

akornich commented Apr 7, 2020

@Lechus , i just wanted to clarify something regarding your request to create

"Any chance to have a Rollbar.NetCore package with :
RollbarServiceCollectionExtensions
public static IServiceCollection AddRollbarLogger(this IServiceCollection services){}
RollbarServiceCollectionExtensions - without dependency on Http?"

Is the reason for it to have just Rollbar logger integration with .NET Core dependency injection infrastructure regardless of it to be used within an ASP.NET Core based application?

@Lechus
Copy link

Lechus commented Apr 9, 2020

WorkerService is not using ASP / HTTP things.
I reviewed your latest changes and the netPlatfromExtension looks good.
BTW: No need for RollbarLoggerFactory class?

In Programcs CreateHostBuilder():
I added these calls and it is working.
ConfigureRollbarSingleton()

services.AddRollbarLogger(loggerOptions =>
                        {
                            loggerOptions.Filter = (loggerName, loglevel) => loglevel >= LogLevel.Error;
                        });

Would be good to have configuration inside AddRollbarLogger?

services.AddRollbarLogger(loggerOptions =>
                        {
                            loggerOptions.Filter = (loggerName, loglevel) => loglevel >= LogLevel.Error;
loggerConfig = (happy default read from Configuration, like rollbar.token and rollbar.environment)
                        });

or provide IRollbarConfig , so a class like MyRollbarConfig with properties like token, env could be populated from ENV / appsettings properties passed to .NET Core IConfiguration.

@mymys91 mymys91 closed this as completed Jul 1, 2020
@akornich
Copy link
Contributor

akornich commented Jul 1, 2020

reopening. i think we can implement a few good points brought up in this thread...

@akornich akornich reopened this Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Denotes a runtime problem within the SDK question
Projects
None yet
Development

No branches or pull requests

3 participants