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 set ConnectionString using ILogger? #1944

Closed
TimothyMothra opened this issue Jun 30, 2020 · 6 comments
Closed

How to set ConnectionString using ILogger? #1944

TimothyMothra opened this issue Jun 30, 2020 · 6 comments
Assignees
Milestone

Comments

@TimothyMothra
Copy link
Member

We have an internal customer using ILogger, and they need to set the ConnectionString but it appears that we don't expose that in the ILogger SDK.

We have a constructor overload that would permit this, but it's currently set to private.

/// <summary>
/// Adds an ApplicationInsights logger named 'ApplicationInsights' to the factory.
/// </summary>
/// <param name="builder">The <see cref="ILoggingBuilder"/> to use.</param>
/// <param name="configureTelemetryConfiguration">Action to configure telemetry configuration.</param>
/// <param name="configureApplicationInsightsLoggerOptions">Action to configure ApplicationInsights logger.</param>
private static ILoggingBuilder AddApplicationInsights(
this ILoggingBuilder builder,
Action<TelemetryConfiguration> configureTelemetryConfiguration,
Action<ApplicationInsightsLoggerOptions> configureApplicationInsightsLoggerOptions)
{

I propose we set this to public to unblock this customer.

@cijothomas do you know of any workarounds?

@cijothomas
Copy link
Contributor

If using, DI then the following should work as shown in doc example
https://docs.microsoft.com/en-us/azure/azure-monitor/app/ilogger#console-application

services.Configure<TelemetryConfiguration>(
            (config) =>
            {
                config.ConnectionString  = "";
            }
        );

@rajkumar-rangaraj
Copy link
Member

There is an active PR #1643 to make this method as public.

@TimothyMothra
Copy link
Member Author

Thanks Raj, We may need to fork this PR and finish it ourselves.

@github-actions
Copy link

This issue is stale because it has been open 300 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the stale label Sep 15, 2021
@cijothomas cijothomas removed the stale label Sep 15, 2021
@TimothyMothra TimothyMothra self-assigned this Sep 16, 2021
@TimothyMothra TimothyMothra added this to the 2.19 milestone Sep 21, 2021
@TimothyMothra TimothyMothra modified the milestones: 2.19, 2.20 Oct 4, 2021
@TimothyMothra TimothyMothra modified the milestones: 2.20, 2.21 Dec 14, 2021
@pawel-zolty
Copy link

Hi I would appreciate if this change will be merged. Azure recommend to use connection string instead of Instrumentation keys. But it is impossible to do when I need to configure Logger in ASP.Net core Program.cs

@cijothomas
Copy link
Contributor

Hi I would appreciate if this change will be merged. Azure recommend to use connection string instead of Instrumentation keys. But it is impossible to do when I need to configure Logger in ASP.Net core Program.cs

Agree. this should be prioritized for the coming release.

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

No branches or pull requests

4 participants