Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在NLog布局中使用SQL语句?_C#_Sql_Asp.net Mvc_Nlog - Fatal编程技术网

C# 如何在NLog布局中使用SQL语句?

C# 如何在NLog布局中使用SQL语句?,c#,sql,asp.net-mvc,nlog,C#,Sql,Asp.net Mvc,Nlog,我知道下面的代码不起作用,但这就是我要做的: <parameter name="@logtype_id" layout="select id from dbo.tracelog where lookup_category = 'Tracelog' and description = '${level}'" /> 您可能会发现使用自定义目标更容易-劳埃德,谢谢!但是它并没有显示任何关于使用SQL语句的内容,我是否像在任何其他c#类中一样使用它?这已经通过自定义布局渲染器解决了,请参

我知道下面的代码不起作用,但这就是我要做的:

 <parameter name="@logtype_id" layout="select id from dbo.tracelog where lookup_category = 'Tracelog' and description = '${level}'" />

您可能会发现使用自定义目标更容易-劳埃德,谢谢!但是它并没有显示任何关于使用SQL语句的内容,我是否像在任何其他c#类中一样使用它?这已经通过自定义布局渲染器解决了,请参见@Julian I发布的问题:无论如何,谢谢!您可能会发现使用自定义目标更容易-劳埃德,谢谢!但是它并没有显示任何关于使用SQL语句的内容,我是否像在任何其他c#类中一样使用它?这已经通过自定义布局渲染器解决了,请参见@Julian I发布的问题:无论如何,谢谢!
<target name="database" xsi:type="Database"
        dbUserName="internwebuser"
        dbProvider="System.Data.SqlClient"
        connectionStringName="SECURE"
        connectionString="Data Source=abc.com;Initial Catalog=Db;User ID=userId;Password=password"
        commandText="insert into dbo.tracelog (user_id, logtype_id, page_name, custom_message, excep_message, insertdate) 
        values 
        (@user_id, @logtype_id, @page_name, @custom_message, @excep_message, @insertdate);" >



  <parameter name="@user_id"            layout="" />
  <parameter name="@logtype_id"         layout="select id from dbo.tracelog where lookup_category = 'Tracelog' and description = '${level}'" />
  <parameter name="@page_name"          layout="${aspnet-request:serverVariable=Url}" />
  <parameter name="@custom_message"     layout="${exception}" />
  <parameter name="@excep_message"      layout="${exception:tostring}" />
  <parameter name="@insertdate"         layout="${date}" />


</target>