我做了很多關於如何在masstransit中記錄數據的研究(在官方文檔,github的問題頁面和stackoverflow)(記住日誌功能從任何日誌實現中分離),甚至在masstransit的github着名示例中作爲Sample-ShoppingWeb,採樣訂房和星巴克我無法理解如何登錄應用程序數據...如何登錄masstransit?
我安裝MassTransit.NLog和波紋管配置我的車:
var bus = BusConfigurator.ConfigureBus((cfg, host) =>
{
...
cfg.ReceiveEndpoint(host, RabbitMqConstants.SagaQueue, e =>
{
cfg.UseNLog();
...
...並給予一看NLOG教程https://github.com/NLog/NLog/wiki/Tutorial我安裝的軟件包NLog.Config(即具有的NuGet依賴NLOG和NLog.Schema) 和我的項目中添加文件NLOG的.config和** NLog.xsd * ... ... 的 問題不在NLOG本身,而是我不能瞭解如何登錄masstransit信息...
在我OrderStateMachine類我做以下
...
Initially(
When(RegisterOrder)
.Then(context =>
{
var log = Logger.Get("logfile");
log.Info(context);
log.InfoFormat("Register Order {0}", "register");
throw new ArgumentException("Test for monitoring sagas");
log.Error(context);
//throw new ArgumentException("Test for monitoring sagas");
...
我不知道即使是類和方法,我應該使用(上masstransit)...