我正在使用log4net和ElasticSearch以及Kibana.到现在为止,我的web.config看起来像这样:
我有一些自定义参数,如位置,标签,mstimeload,applicationid,页面,ipclient,...一切正常,但所有这些参数都是string
类型,而我想也有integer
或geo_point
类型,但我不知道如何告诉log4net哪个类型是我的参数.然后在c#中我写这样的日志:
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); log4net.ThreadContext.Properties["label"] = label; log4net.ThreadContext.Properties["ipclient"] = ipaddress; log4net.ThreadContext.Properties["browser"] = browserType; log4net.ThreadContext.Properties["browsersignature"] = browserHashSignature; log4net.ThreadContext.Properties["appversion"] = ASSettings.ApplicationVersion; log4net.ThreadContext.Properties["mstimeload"] = msTime == null ? null : Convert.ToString(Convert.ToInt32(msTime.Value), CultureInfo.InvariantCulture); log4net.ThreadContext.Properties["globalcountertailsloaded"] = globalCounter_tilesloaded == null ? null : Convert.ToString(globalCounter_tilesloaded.Value, CultureInfo.InvariantCulture); log4net.ThreadContext.Properties["ipserveraddress"] = ipserveraddress; log4net.ThreadContext.Properties["page"] = page; log4net.ThreadContext.Properties["sessionuniquecodetag"] = sessionuniquecodetag; log4net.ThreadContext.Properties["applicationid"] = applicationid; log4net.ThreadContext.Properties["location"] = ASSecurity.GetLatLongFromIp(ipaddress); log.Error(description, ex);
但我不确定这是否是最佳方式,或者是否还有其他方法.