2012-05-31 38 views
0

我正在嘗試使用NLog 2.0將日誌寫入xml文件。在.net framework 3.5中。NLog配置 - 登錄到xml - 將自定義值傳遞到Log4JXmlEventLayout

這是我使用的佈局。

layout =「$ {log4jxmlevent:includelongdate = true:includeexception = true:includeSourceInfo = true:includeCallSite = true:appInfo = true:includeNLogData = true:includestacktrace = true:throwExceptions = true:includeerror = true:indentXml = true :includeNLogData = true}「>

但是,這並沒有給我正確的模塊或類名稱或記錄器,因爲在數據庫配置佈局=」$ {logger:shortName = true}「。

反正有沒有在xml config中獲取有關模塊/類/記錄器名稱的更多信息?

回答

0

我可以通過使用NLog.MappedDiagnosticsContext

NLog.MappedDiagnosticsContext.Set(簡稱 「計劃」,ex.Source)解決我的問題; NLog.MappedDiagnosticsContext.Set(「Alert」,「High」);