从ASP.NET Core 3.1到Oracle数据库的记录错误

发布于 01-22 14:42 字数 1896 浏览 2 评论 0原文

我想记录从 .NET Core Web API到Oracle数据库的异常。

我开始使用 nlog ,但没有登录数据库。另外,InternallogFile存在错误。

  • 我正在使用的以下版本 - asp.net core -v3.1,
    nlog.web.aspnetcore“ -v4.14.0,
    Oracle.ManagedDataAccess.Core -2.19.80

  • 另外,在nlog github中,它写成使用特定的db客户端,并且使用了以下dbprovider-使用 - dbprovider =“ oracle.manageddataaccess.client.oracleconnection,oracle.manageddataaccess
    但是我正在使用oracle.manageddataaccess.core而不是oracle.manageddataaccess,这会引起任何问题吗?

  • 下面是我的nlog.config

     < nlog xmlns =“ http://www.nlog-project.org/schemas/nlog.xsd”
         XMLNS:XSI =“ http://www.w3.org/2001/xmlschema-instance”
         XSI:示意图=“ http://www.nlog-project.org/schemas/nlog.xsd nlog.xsd”
         自动加载=“ true”
         throwExceptions =“ true”
         internalloglevel =“ error” internallogFile =“ c:\ internalScopeWizardLogs \ nlog.log”>
         <扩展>
         <添加汇编=“ nlog.web.aspnetcore”/>
         </Extensions>
          < targets>
         <! - 将数据写入db-> 
         < target XSI:type =“数据库”
         名称=“ dbtarget”
         connectionsTring =“ data source =(description =(address =(stolopty = tcp)(host = insert_host)));用户 
     id = insert_user_id; password = insert_password
         dbprovider =“ oracle.manageddataaccess.client.oracleconnection,oracle.manageddataaccess”
         commandText =“插入tsd_error_logs(errmessage,errlevel,errexception,errlogger) 
     值 
         (:msg,:evel,:异常,:logger)”
         commandType =“ text”>
         <参数名称=“ msg” layout =“ $ {message}” />
        <参数name =“ level” layout =“ $ {level}” />
         <参数名称=“异常” layout =“ $ {exception}” />
         <参数名称=“ logger” layout =“ $ {logger}” />
         </target>
         </targets>
         <规则>
         < logger name =“*” lacte =“错误,警告,致命,跟踪” writeto =“ dbtarget” />  
         </rules>
         </nlog>
     

I want to log exceptions from .Net Core Web API to Oracle database.

I started using NLog but nothing is getting logged into the database. Also, there is error in the internalLogFile.

  • The below version I'm using - ASP.Net Core - v3.1,
    NLog.Web.AspNetCore" - v4.14.0,
    Oracle.ManagedDataAccess.Core - 2.19.80

  • Also, in the NLog GitHub, it is written to use specific db clients and the below dbProvider is used -
    dbProvider="Oracle.ManagedDataAccess.Client.OracleConnection, Oracle.ManagedDataAccess"
    But I'm using Oracle.ManagedDataAccess.Core instead of Oracle.ManagedDataAccess, will this cause any issue ?

  • Below is my NLog.config

         <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
         autoReload="true"
         throwExceptions="true"
         internalLogLevel="Error" internalLogFile="C:\InternalScopeWizardLogs\nlog.log">
         <extensions>
         <add assembly="NLog.Web.AspNetCore"/>
         </extensions>
          <targets>
         <!--Writing data into db--> 
         <target xsi:type="Database"
         name="dbTarget"
         connectionString="Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=INSERT_HOST));User 
     Id=INSERT_USER_ID;Password= INSERT_PASSWORD"
         dbProvider="Oracle.ManagedDataAccess.Client.OracleConnection, Oracle.ManagedDataAccess"
         commandText="INSERT INTO TSD_ERROR_LOGS (ERRMESSAGE,ERRLEVEL,ERREXCEPTION,ERRLOGGER) 
     VALUES 
         (:msg,:level,:exception,:logger)"
         commandType ="Text">
         <parameter name="msg" layout="${message}" />
        <parameter name="level" layout="${level}" />
         <parameter name="exception" layout="${exception}" />
         <parameter name="logger" layout="${logger}" />
         </target>
         </targets>
         <rules>
         <logger name="*" levels="Error,Warn,Fatal,Trace" writeTo="dbTarget" />  
         </rules>
         </nlog>
    

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文