Closed shah-keyur closed 6 years ago
It would be good if you add working example to log from a controller.
Thanks,
You might want to check out the ASP.NET Core logging documentation referenced at the top of the readme; it shows how to use a logger from a controller as well as how to add custom providers like this one. I would follow the steps there and make sure console logging is working from your controller before adding the GELF provider.
The apps in the /samples
directory are for those building console apps that are not using ASP.NET, but you could still run one and check that it sends logs to your Graylog server.
Thanks,
Yeah from the sample application it is working.
Need figure it out why not working in the my application.
Thanks, -Keyur
It sounds like it would help if I added an example ASP.NET app. I'll try to get one up within the next few days. Hopefully you figure out your issue before then!
I suspect the version the one which is working with a controller is Aspnetcore 2.0 and I am using 2.1 preview final 2
In theory it should still work, I'll have to look into it.
I have added a sample ASP.NET Core 2.0 project here in case that helps.
Hi MattwCole,
I confirm that its the issue with AspnetCore2.1.
I try to reproduce it with a sample project and it doesn't work. Then I changed the AspnetCore2.0 and it worked.
Thanks, Keyur
Thanks for confirming this. Now that we know what the problem is, I will close this issue. Support for 2.1 will be tracked in #9.
Appreciate your help!
Hi ,
Based on the sample example for .NeCore2
I have configure GelfLogger and then injecting the Ilogger
.
Then using the logger.LogInformation("Log in gray log").
But its not appears in the Graylog.
On application start I am logging exactly as the sample example and its logs in gay log but not from controller.
`public void ConfigureServices(IServiceCollection services) { services.Configure(Configuration.GetSection("Graylog"))
.AddLogging(loggingBuilder => loggingBuilder
.AddConfiguration(Configuration.GetSection("Logging"))
.AddGelf());
using (var serviceProvider = services.BuildServiceProvider()) { UseLogger(serviceProvider.GetRequiredService<ILogger>());
}
}`
private static void UseLogger(ILogger logger)
{
const string framework = "netcoreapp-4.0";
public ValueController( ILogger logger) { this.logger = llogger;
public async Task GetValues()
{
try
{
using .net core 2.1 final previews 2
Appreciate your help.
Thanks, Keyur