使用Nlog登录数据库和文本文件

编程入门 行业动态 更新时间:2024-10-27 21:18:48
本文介绍了使用Nlog登录数据库和文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

之前我已经使用过log4net而不需要编写任何代码只需在配置文件中进行一些配置来记录错误。现在我想使用Nlog做同样的事情,但无法做到这一点。有些人可以向我展示如何使用Nlog进行日志记录。我在配置文件中尝试了以下代码

Hi, I have used log4net before where there was no need to write any code just do some configuration in config file to log the errors. Now i want to do same using Nlog but couldnt achieve this . Can some show me sample how to log using Nlog. I tried below code in config file

<nlog> <targets> <target name="file" layout="${longdate} ${logger} ${message}" filename="${basedir}/logs/logfile.txt" xmlns:xsi="#unknown" /> </targets> <rules> <logger name="*" minlevel="Off" writeto="file" /> </rules> </nlog>

并试图在控制器中引发错误,但它没有创建日志文件。上面的代码有什么问题

and tried to raise error in controller but its not creating log file. Is anything wrong in above code

推荐答案

{longdate} {longdate}

{logger}

{message}filename = {message}" filename="

更多推荐

使用Nlog登录数据库和文本文件

本文发布于:2023-07-09 00:19:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1082118.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文本文件   数据库   Nlog

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!