首页 > 解决方案 > InvalidOperationException - 无法构造类型 LogWriter。您必须配置容器以提供此值

问题描述

当我尝试从 BizTalk 业务流程中记录某些内容时,我在事件日志中收到以下错误消息。

Error using Info(System.String,System.String): Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The type LogWriter cannot be constructed. You must configure the container to supply this value.
-----------------------------------------------
At the time of the exception, the container was:

  Resolving Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter,(none)
 Inner exception: The type LogWriter cannot be constructed. You must configure the container to supply this value.

为了登录 BizTalk 业务流程,我创建了一个使用 Microsoft Enterprise Library 5 的自定义 .net 组件。Entlib 日志记录的配置位于专用文件中,并且来自 BizTalk 配置文件,BTSNTSvc.exe.config并且引用BTSNTSvc64.exe.config了该entlib.config文件。我正在使用 BizTalk 2016 和 VS2015。

我正在尝试在平面文本文件中记录文本。

标签: logging.net-4.0enterprise-libraryenterprise-library-5biztalk-2016

解决方案


有一个关于这个问题的 msdn 论坛主题。https://social.msdn.microsoft.com/Forums/en-US/8edb589c-a488-49ec-aca7-5c5219940fbb/biztalk-enterprise-library-logging-issue?forum=biztalkgeneral

不确定您为什么要尝试使用企业库将日志跟踪到文本文件。ETW 是为此目的而推荐的高性能仪器。请参阅文章https://social.technet.microsoft.com/wiki/contents/articles/30523.biztalk-server-2013-r2-instrumenting-an-orchestration-with-etw.aspx


推荐阅读