使用Nlog登录数据库和文本文件 [英] Logging in database and text file using Nlog

查看:112
本文介绍了使用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登录数据库和文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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