You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am not quite sure if this is the right place to report this.
I am working on a .NET console app that uses Dependency Injection. The app also uses a Common library that contains abstractions that are shared with all apps in the project.
The Common library uses AzureBlob storage and Azure Service Bus. It contains a static method that, when called, injects these libraries.
This static method is then called in the Program.cs of the main app:
private static ServiceProvider BuildDI(IConfiguration configuration)
{
//create a serviceProvider
IServiceCollection services = new ServiceCollection();
services.AddCommonServices(configuration); // static method in CommonServices called here
//add the main program to run
services.AddSingleton<IRunner, Runner>();
//add logging
services.AddLogging(loggingBuilder =>
{
loggingBuilder.ClearProviders();
loggingBuilder.SetMinimumLevel(LogLevel.Trace);
loggingBuilder.AddNLog(configuration);
});
return services.BuildServiceProvider();
}
When I run the main project and use the Log:
private readonly ILogger<Runner> _logger;
public Runner(ILogger<Runner> logger)
{
_logger = logger;
}
public void DoTask()
{
_logger.LogInformation("Hello world");
}
The log is not written to the file.
Interestingly, the log folder shows the internal.log files but doesn't show the nlog-all-xxxx-xx-xx.log file.
If I comment out the part of the static file that adds the Azure SDK:
//services.AddAzureClients(builder =>
//{
// builder.AddBlobServiceClient(Configuration.GetSection(StorageAccountConfig.ConfigName)["ConnectionString"]);
// builder.AddServiceBusClient(Configuration.GetSection(ServiceBusConfig.ConfigName)["ConnectionString"])
// .ConfigureOptions(opt =>
// {
// opt.TransportType = ServiceBusTransportType.AmqpWebSockets; //set the transport type to AmqpWebSockets so that the ServiceBusClient uses the port 443
// });
//});
Then the logging works fine.
When I inspect the _logger when running, this is what I see:
Hello team,
I am not quite sure if this is the right place to report this.
I am working on a .NET console app that uses Dependency Injection. The app also uses a Common library that contains abstractions that are shared with all apps in the project.
The Common library uses AzureBlob storage and Azure Service Bus. It contains a static method that, when called, injects these libraries.
Here is the code for the static method:
This static method is then called in the Program.cs of the main app:
When I run the main project and use the Log:
The log is not written to the file.
Interestingly, the log folder shows the
internal.log
files but doesn't show thenlog-all-xxxx-xx-xx.log
file.If I comment out the part of the static file that adds the Azure SDK:
Then the logging works fine.
When I inspect the
_logger
when running, this is what I see:NLog version: 5.3.2
NLog Extension Version: 5.3.10
Platform: .NET8
Current NLog config (xml or C#, if relevant)
What is the current result?
Only internal.log is written.
What is the expected result?
Both log files should be written.
Did you checked the Internal log?
Yes
Please post full exception details (message, stacktrace, inner exceptions)
N/A
Are there any workarounds? Yes
Is there a version in which it did work?
N/A
Can you help us by writing an unit test?
Not sure what to test.
The text was updated successfully, but these errors were encountered: