我想从 nlog 获取值并将它们放入数据库中,但是当我使用当前代码运行我的应用程序时,它会引发异常并显示以下消息;
Must declare the scalar variable \"@MachineName\"."}
这是我的 nlog.config 文件,任何帮助将不胜感激 =]
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" autoReload="true">
<!--
See http://nlog-project.org/wiki/Configuration_file
for information on customizing logging rules and outputs.
-->
<targets>
<target xsi:type="Database"
name="Database"
dbProvider="sqlserver"
useTransactions="true"
connectionString="Data Source=AC-02\SQLEXPRESS;Initial Catalog=Modelfirst.Blogging;Integrated Security=True"
keepConnection="true"
commandText="INSERT INTO Logs (Machine_Name, Username, Logon_Time, Screensaver_On, Screensaver_Off, Logoff_Time, Program_Start) Values (@MachineName, @Username, @LogonTime, @Screensaver_On, @Screensaver_Off, @LogoffTime, @ProgramStart)"
/>
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="Database" />
</rules>
</nlog>