将log4net插入(空)到自定义列 [英] log4net inserting (null) into custom column

查看:103
本文介绍了将log4net插入(空)到自定义列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据建议在此处添加自定义列.每当我使用代码行将某些内容登录到此列中时,一切工作就很好了

Added a custom column as suggested here. Things are working fine when ever I log something into this column using the code line

log4net.GlobalContext.Properties["CustomColumn"] = "Custom value";

但是如果我通过null代替,如下所示:

But if I pass null instead as below

log4net.GlobalContext.Properties["CustomColumn"] = null;

此记录为(空)(brickts中包含的字符串null).如果我根本不登录,也会发生这种情况,就像我注释如下所示的代码一样.

this is logged as (null)(a string null included in brakets). This also happens if I do not log at all, like I comment the code as shown below.

//log4net.GlobalContext.Properties["CustomColumn"] = null;

所以问题是,是否有办法使它在数据库中实际上为空,而不是字符串-(null).我正在使用ms sql server 2008 r2

So the question is, is there a way to make it actually null in the database, instead of a string - (null). I am using ms sql server 2008 r2

推荐答案

尝试一下

log4net.GlobalContext.Properties["CustomColumn"] = DBNull.Value;

这篇关于将log4net插入(空)到自定义列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆