I use nlog dll(version 3.1.0.0) to write to database - oracle with entity frameWork in the line :
logger.Log(logLevel, "try");
I get in the logs of nlog the following error:
Error Error when writing to database System.ArgumentException: Value does not fall within the expected range. at Oracle.ManagedDataAccess.Client.OracleCommand.set_CommandType(CommandType value) at NLog.Targets.DatabaseTarget.WriteEventToDatabase(LogEventInfo logEvent) at NLog.Targets.DatabaseTarget.Write(LogEventInfo logEvent)
the code is:
SetPropGDC(LogEntity);
NLog.LogLevel logLevel = SetLogLevel(Level.Debug);
logger.Log(logLevel, "try");
ClearGDC();
private static LogLevel SetLogLevel(Level level)
{
switch (level)
{
case Level.Debug: return LogLevel.Debug;
case Level.Error: return LogLevel.Error;
case Level.Fatal: return LogLevel.Fatal;
case Level.Info: return LogLevel.Info;
default: return LogLevel.Error;
}
}
private void SetPropGDC(LogEntity LogEntity)
{
GlobalDiagnosticsContext.Set("connectionString", _unitOfWork.getConnectionString());
GlobalDiagnosticsContext.Set(processId, LogEntity.PROCESS_ID.ToString());
GlobalDiagnosticsContext.Set("TIME_STAMP", LogEntity.TIME_STAMP.ToString());
GlobalDiagnosticsContext.Set(customerId, LogEntity.CUSTOMER_ID.ToString());
GlobalDiagnosticsContext.Set("REQUEST", LogEntity.REQUEST.ToString());
GlobalDiagnosticsContext.Set("RESPONSE", LogEntity.RESPONSE.ToString());
GlobalDiagnosticsContext.Set("EXCEPTION", LogEntity.EXCEPTION.ToString());
GlobalDiagnosticsContext.Set("STACK_TRACE", LogEntity.STACK_TRACE.ToString());
GlobalDiagnosticsContext.Set("DETAILS", LogEntity.DETAILS.ToString());
}
<targets>
<target name="TRACEDatabase" type="DataBase" keepConnection="false"
dbProvider="Oracle.ManagedDataAccess.Client" connectionString="${gdc:connectionString}"
commandText="insert into TLOG_SITE_GENERAL_TRACE( PROCESS_ID,TIME_STAMP,CUSTOMER_ID,LOG_LEVEL,REQUEST,RESPONSE,EXCEPTION,STACK_TRACE,MESSAGE)
values(:PROCESS_ID,:TIME_STAMP,:CUSTOMER_ID,:LOG_LEVEL,:REQUEST,:RESPONSE,:EXCEPTION,:STACK_TRACE,:MESSAGE)">
<parameter name="PROCESS_ID" layout="${gdc:PROCESS_ID}" />
<parameter name="TIME_STAMP" layout="${gdc:TIME_STAMP}" />
<parameter name="CUSTOMER_ID" layout="${gdc:CUSTOMER_ID}" />
<parameter name="LOG_LEVEL" layout="${level:uppercase=true}" />
<parameter name="REQUEST" layout="${gdc:REQUEST}" />
<parameter name="RESPONSE" layout="${gdc:RESPONSE}" />
<parameter name="EXCEPTION" layout="${gdc:EXCEPTION}" />
<parameter name="STACK_TRACE" layout="${gdc:STACK_TRACE}" />
<parameter name="MESSAGE" layout="${message}" />
</target>
Can anyone help?