Open walunjsachin opened 5 years ago
@walunjsachin Try removing the BufferingTargetWrapper
and just write directly to blob-target.
There is also something called Azure Streaming, where you configure the azure-function to have its console-output (or trace-output) to be forwarded to azure-blob. This should be more reliable for azure-functions as they have "sudden shutdown" and if no explicit flush, then data might get lost.
And you have the magic code to register FunctionsStartup
:
[assembly: FunctionsStartup(typeof(MyNamespace.Startup))]
See also: https://docs.microsoft.com/bs-latn-ba/azure/azure-functions/functions-dotnet-dependency-injection
And you have setup loglevel filters in host.json
:
{
"version": "2.0",
"logging": {
"logLevel": {
"default": "Information"
}
}
}
Alternative you could try this:
public override void Configure(IFunctionsHostBuilder builder)
{
builder.Services.AddLogging(loggingBuilder =>
{
loggingBuilder.ClearProviders();
loggingBuilder.SetMinimumLevel(LogLevel.Trace);
loggingBuilder.AddNLog();
});
}
And you have setup loglevel filters in
host.json
:{ "version": "2.0", "logging": { "logLevel": { "default": "Information" } } }
Alternative you could try this:
public override void Configure(IFunctionsHostBuilder builder) { builder.Services.AddLogging(loggingBuilder => { loggingBuilder.ClearProviders(); loggingBuilder.SetMinimumLevel(LogLevel.Trace); loggingBuilder.AddNLog(); }); }
I had already tried, it was erroring out since all default providers were removed and there was no logging happening to azure storage
And you have the magic code to register
FunctionsStartup
:
[assembly: FunctionsStartup(typeof(MyNamespace.Startup))]
See also: https://docs.microsoft.com/bs-latn-ba/azure/azure-functions/functions-dotnet-dependency-injection
I am using the same to register Nlog in startup and configure method.
There is also something called Azure Streaming, where you configure the azure-function to have its console-output (or trace-output) to be forwarded to azure-blob. This should be more reliable for azure-functions as they have "sudden shutdown" and if no explicit flush, then data might get lost.
I intend to use Nlog target which helps me for using consistent log format and support for other targets at same time. Also did try using Nlog Trace target but it did not log data to Azure storage
I had already tried, it was erroring out since all default providers were removed and there was no logging happening to azure storage
And what happened when you just configured loglevel host.json
? (Without calling ClearProviders
)
I am using the same to register Nlog in startup and configure method.
Good to hear that you have setup everything correctly.
Also did try using Nlog Trace target but it did not log data to Azure storage
Again it is just me guessing. Maybe the use of Trace-target is no longer valid with Azure Functions v2. Never used Azure Functions in my life.
But it sounds like the code in https://github.com/NLog/NLog/issues/3538 is somehow working. But if you find the missing details for things to work, then please give your input to:
I had already tried, it was erroring out since all default providers were removed and there was no logging happening to azure storage
And what happened when you just configured loglevel
host.json
? (Without callingClearProviders
)I am using the same to register Nlog in startup and configure method.
Good to hear that you have setup everything correctly.
Also did try using Nlog Trace target but it did not log data to Azure storage
Again it is just me guessing. Maybe the use of Trace-target is no longer valid with Azure Functions v2. Never used Azure Functions in my life.
But it sounds like the code in NLog/NLog#3538 is somehow working. But if you find the missing details for things to work, then please give your input to:
Yes, this is one way to do by explicitly creating logger. I want to utilize the DI available in Azure function (.net Core) applications.
I am troubleshooting issue to configure azure blob storage target with below implementation for doing DI in azure function v2 , there is no Nlog errors. I have trace enabled no error and can see target initialized but there is no log going to blob storage no traffic in fiddler too...
https://github.com/NLog/NLog/issues/3538