Итак, у меня есть цель базы данных для записи логов в таблицу базы данных Oracle, но я не могу заставить ее записывать в таблицу.Я пробовал разные dbProviders и обычно получаю сообщение об ошибке, как показано ниже:
<target name="database" xsi:type="Database" connectionString="${var:ConnectionStrings}" dbProvider="Oracle.ManagedDataAccess.Client.OracleConnection, Oracle.ManagedDataAccess"
commandType="Text" keepConnection="false"
commandText="INSERT INTO SAMS.LOG (ID, LOGLEVEL, MESSAGE, LOGGER, CALLSITE, EXCEPTIONDETAIL, USERNAME, IPADDRESS)
VALUES('',
:LogLevel,
:Message,
:Logger,
:Callsite,
:ExceptionType,
:UserName,
:IpAddress);" >
<parameter name="Logged" layout="${date}" />
<parameter name="LogLevel" layout="${level}" />
<parameter name="Message" layout="url: ${aspnet-request-url} | action: ${aspnet-mvc-action} | ${message}" />
<parameter name="Logger" layout="${logger}" />
<parameter name="Callsite" layout="${callsite:filename=true}" />
<parameter name="ExceptionType" layout="${exception:tostring}" />
<parameter name="UserName" layout="${aspnet-user-identity}" />
<parameter name="IpAddress" layout=" ${aspnet-request-ip}" />
</target>
Это самое дальнее, что я смог получить в процессе.Он попытался записать в базу данных, но что-то не так в моей строке подключения.
2018-10-23 14:13:28.1934 Error DatabaseTarget(Name=database_wrapped): Error when writing to database. Exception: Oracle.ManagedDataAccess.Client.OracleException (0x80004005): ORA-12514: TNS:listener does not currently know of service requested in connect descriptor ---> OracleInternal.Network.NetworkException (0x000030E2): ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
at OracleInternal.Network.OracleCommunication.DoConnect(String tnsDescriptor)
at OracleInternal.ServiceObjects.OracleConnectionImpl.Connect(ConnectionString cs, Boolean bOpenEndUserSession, OracleConnection connRefForCriteria, String instanceName)
at OracleInternal.ConnectionPool.PoolManager`3.Get(ConnectionString csWithDiffOrNewPwd, Boolean bGetForApp, OracleConnection connRefForCriteria, String affinityInstanceName, Boolean bForceMatch)
at OracleInternal.ConnectionPool.OraclePoolManager.Get(ConnectionString csWithNewPassword, Boolean bGetForApp, OracleConnection connRefForCriteria, String affinityInstanceName, Boolean bForceMatch)
at OracleInternal.ConnectionPool.OracleConnectionDispenser`3.Get(ConnectionString cs, PM conPM, ConnectionString pmCS, SecureString securedPassword, SecureString securedProxyPassword, OracleConnection connRefForCriteria)
at Oracle.ManagedDataAccess.Client.OracleConnection.Open()
at NLog.Targets.DatabaseTarget.OpenConnection(String connectionString)
at NLog.Targets.DatabaseTarget.EnsureConnectionOpen(String connectionString)
at NLog.Targets.DatabaseTarget.WriteEventToDatabase(LogEventInfo logEvent)
at NLog.Targets.DatabaseTarget.Write(IList`1 logEvents)
Мой appsettings.json содержит строку подключения
"ConnectionStrings": {
"NLogDb": "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)
(HOST=fleetqadb.xxx.com)(PORT=1521))(CONNECT_DATA=
(SERVICE_NAME=orcl.fleetqadb.xxx.com)));User
Id=samsuser;Password=xxxxx;",
}
Если у кого-то есть идеи, яБуду очень признателен!