登录到ASP.NET Core MVC 6中的数据库 [英] Logging to database in ASP.NET Core MVC 6

查看:277
本文介绍了登录到ASP.NET Core MVC 6中的数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的旧MVC5项目中,所有日志信息都通过log4net保存在sql服务器数据库中.我想保留ASP.NET 5的记录器结构,而无需再使用log4net.是否可以将日志保存在数据库表中?我应该使用哪种代码?

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?

推荐答案

您可以实现ILoggerFactoryILogger,但是您希望包括例如登录数据库.

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

下面是使用ILogger实现的示例 EntityFramework 6将日志保存到数据库.

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

这篇关于登录到ASP.NET Core MVC 6中的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆