首页 新闻 会员 周边 捐助

NLog.NLogConfigurationException: Target logfile not found.

0
悬赏园豆:10 [已关闭问题] 关闭于 2015-03-02 21:34

使用NLog的代码 :

Logger logger = LogManager.GetCurrentClassLogger();
LogEventInfo lei = new LogEventInfo();
lei.Properties["Operator_name"] = Opeator_Name;
lei.Properties["Operator_Type"] = Operator_Type;
lei.Properties["DateTime"] = DateTime.Now;
lei.Properties["IP"] = GetClientIPOrAdd.GetIP();
lei.Properties["Operation"] = Operation;
lei.Level = LogLevel.Info;
logger.Log(lei);

编译没问题,在运行的时候, 'Logger logger = LogManager.GetCurrentClassLogger();'出现错误提示:

NLog.NLogConfigurationException: Target logfile not found.

 

我的NLog.config文件:

<target xsi:type="Database" name="LogOnlog" connectionStringName ="DataBase" >
<commandText>
Insert into MyLog(Operator_name,Operator_Type,IP,DateTime,Operation) Values(@Operator_name,@Operator_Type,@IP,@DateTime,@Operation);
</commandText>
<parameter name = "@Operator_name" layout = "${event-context;item=Operator_name}"/>
<parameter name = "@Operator_Type" layout = "${event-context;item=Operator_Type}" />
<parameter name = "@DateTime" layout = "${event-context;item=DateTime}"/>
<parameter name = "@IP" layout = "${event-context;item=IP}" />
<parameter name = "@Operation" layout = "${event-context;item=Operation}" />

</target>

</targets>

<rules>
<logger name="*" minlevel="Trace " writeTo="LogOnlog"/>
</rules>
泰德的主页 泰德 | 初学一级 | 园豆:6
提问于:2015-03-01 14:29
< >
分享
所有回答(1)
0

http://www.cnblogs.com/tider1999/p/4308440.html

泰德 | 园豆:6 (初学一级) | 2015-03-02 21:34
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册