Logging to database in ASP.NET Core MVC 6

2019-03-29 22:13发布

In my old MVC5 project all log informations was saved on a sql server database through log4net. I would like keep logger structure of ASP.NET 5 without using any more the log4net. Is it possibile saving the logs on a database table? What kind of code should I use?

2条回答
【Aperson】
2楼-- · 2019-03-29 22:34

I've created new project that is a bit more flexible and available for Entity Framework Core. Here is the GitHub project site:

https://github.com/msmolka/ZNetCS.AspNetCore.Logging.EntityFrameworkCore

查看更多
甜甜的少女心
3楼-- · 2019-03-29 22:37

You can implement ILoggerFactory and ILogger however you like including, for example, logging to a database.

Here's an example of an ILogger implementation that uses EntityFramework 6 to save logs to a database.

查看更多
登录 后发表回答