c# - Log4net 记录到 Oracle 在记录到数字字段时抛出错误?

标签 c# .net oracle log4net

我已经为这个问题斗争了很长一段时间。当我尝试登录到 Oracle 11g 数据库中的 Number(38,0) 字段时。我收到此错误:

log4net:ERROR [AdoNetAppender] ErrorCode: GenericFailure. Exception while writing to database System.FormatException: Input string was not in a correct format. at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)

      <parameter>
        <parameterName value=":my_param" />
        <dbType value="Int32" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%property{my_param}" />
        </layout>
      </parameter>

我试过设置 Int32 的大小。我已经尝试过 decimal 和 decimal 设置比例和精度。我不确定还能做什么,但我知道当前的值是数字。

这是一些调用记录器进行记录的代码,以及默认值的位置。

log4net.LogicalThreadContext.Properties[":my_param"] = 132;
log.Info("Application Start");  //Error occurs here in the output window

最佳答案

当您将 my_param 属性添加到 LogicalThreadContext 时,您想删除该冒号。

log4net.LogicalThreadContext.Properties["my_param"] = 132;

目前您对 %property 语法的使用与您要添加的属性的名称不匹配。

关于c# - Log4net 记录到 Oracle 在记录到数字字段时抛出错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40642854/

相关文章:

c# - EF 和 IHostedService 的多个实例

c# - 保存 Winform 窗体控件状态的最佳方法?

oracle - 带有 oracle 12c 的 Windows 的 Docker 镜像

sql - 如何只存储时间;不是日期和时间?

c# UWP BluetoothLEDevice.FromIdAsync System.IO.FileNotFoundException 收藏

c# - RabbitMQ basic.return

c# - BindingList<T>.Sort() 表现得像 List<T>.Sort()

c# - 计算不同的结果-方法 PointToScreen 获取桌面(屏幕)相关控件的点

sql - oracle 10g中如何缓存函数的查询结果?

c# - TFS/VS 错误地将文件标记为有更改?