问题标签 [common.logging]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
8 回答
38756 浏览

c# - 无法从配置部分 'common/logging' 获取 Common.Logging 的配置

我正在尝试使用以下日志记录程序集配置控制台应用程序:

  • Common.Logging.dll (2.1.0.0)
  • Common.Logging.Log4Net1211.dll (2.1.0.0)
  • log4net.dll (1.2.11.0)

如果记录器以编程方式配置,那么一切正常:

但是如果我尝试使用以下配置文件启动它,它就会爆炸:

这些是相关的错误消息:

似乎无法解析我的配置文件,有谁知道正确的格式应该是什么,还是其他什么问题?我使用官方文档创建了我的配置文件。

0 投票
1 回答
589 浏览

azure - 在 Azure 中配置 common.logging

我正在开发一个应用程序。使用 Common.Logging (http://netcommon.sourceforge.net/index.html)。一个简化的日志配置(在 web.config 中完成)如下:

正如您在此处看到的,配置指向后端日志记录框架的另一个配置文件(此处为 NLog.config)。

我的问题是:在 Azure 中部署时,我应该在此处指定什么路径(在 dev 上,NLog.config 在构建解决方案时被复制,并放在 bin 目录中)。换句话说,获取应用程序在 Azure 中部署的物理位置的最安全方法是什么?

提前致谢!

0 投票
1 回答
5664 浏览

c# - common.logging - Redirect found in application configuration file

I added common.logging.log4net to my visual studio 2012 solution via nuget.

common.logging.log4net ver. - 2.0.1 common.logging ver. - 2.0.0 log4net - ver. 1.2.10

When I build/run it locally, I see the following exception via browser:

Could not load file or assembly 'Common.Logging' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileLoadException: Could not load file or assembly 'Common.Logging' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Stack Trace:

[FileLoadException: Could not load file or assembly 'Common.Logging' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]

[FileLoadException: Could not load file or assembly 'Common.Logging, Version=2.1.1.0, Culture=neutral, PublicKeyToken=af08829b84f0328e' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)] System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +210
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +242
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +17 System.Reflection.Assembly.Load(String assemblyString) +35
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +122

It is looking for Common.Logging Version=2.1.1.0, which it can't find because it is not loaded. Now when I debug the app, I see the following exception, which is a bit different:

LOG: This bind starts in default load context.

LOG: Using application configuration file: C:\Workspaces\FTM\Apps\TM\TM.Web\web.config

LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config

LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.

LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).

LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/e97e0952/56ab271f/Common.Logging.DLL.

LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/e97e0952/56ab271f/Common.Logging/Common.Logging.DLL.

LOG: Attempting download of new URL file:///C:/Workspaces/FTM/Apps/TM/TM.Web/bin/Common.Logging.DLL.

LOG: Using application configuration file: C:\Workspaces\FTM\Apps\TM\TM.Web\web.config

LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config

LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.

LOG: Redirect found in application configuration file: 2.0.0.0 redirected to 2.1.1.0.

LOG: Post-policy reference: Common.Logging, Version=2.1.1.0, Culture=neutral, PublicKeyToken=af08829b84f0328e

LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/e97e0952/56ab271f/Common.Logging.DLL.

LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/e97e0952/56ab271f/Common.Logging/Common.Logging.DLL.

LOG: Attempting download of new URL file:///C:/Workspaces/FTM/Apps/TM/TM.Web/bin/Common.Logging.DLL. WRN: Comparing the assembly name resulted in the mismatch: Minor Version ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

Stack Trace:

[FileLoadException: Could not load file or assembly 'Common.Logging' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]

[FileLoadException: Could not load file or assembly 'Common.Logging, Version=2.1.1.0, Culture=neutral, PublicKeyToken=af08829b84f0328e' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)] System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +210
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +242
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +17 System.Reflection.Assembly.Load(String assemblyString) +35
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +122

[ConfigurationErrorsException: Could not load file or assembly 'Common.Logging, Version=2.1.1.0, Culture=neutral, PublicKeyToken=af08829b84f0328e' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +12761078
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +503 System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +142 System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +334
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath) +203
System.Web.Compilation.BuildManager.ExecutePreAppStart() +152
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1151

[HttpException (0x80004005): Could not load file or assembly 'Common.Logging, Version=2.1.1.0, Culture=neutral, PublicKeyToken=af08829b84f0328e' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12881540 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12722601

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17929

Not sure why its trying to redirect to 2.1.1.0 (according to the logs)

Tom

0 投票
3 回答
15066 浏览

c# - Quartz.Net - 使用 log4net 进行通用日志记录

我正在尝试实现 Quartz.Net。只要没有配置日志记录,一切正常(调试输出显示“未找到配置部分 - 抑制日志记录输出”)。

启用日志记录后,我将收到以下错误:Failed getting configuration for Common.Logging from configuration section 'common/logging'

内部异常:为 common/logging 创建配置节处理程序时出错:无法创建类型“Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter,Common.Logging.Log4net”

我使用了几种资源验证我的配置,但据我所知,它应该是正确的。

我的 app.config:

我引用了以下程序集:
quartz.dll,版本 2.01.100
common.logging.dll,版本 2.0.0.0
common.logging.log4net.dll,版本 2.0.0.0
log4net.dll,版本 1.2.10.0

我找不到给出错误的原因。欢迎所有帮助,显然我忘记了一些事情......

0 投票
2 回答
3651 浏览

c# - 'LogManager' 是 .LogManagers 之间的模棱两可的引用

我收到错误消息,“错误 19 'LogManager' 是 'Common.Logging.LogManager' 和 'NLog.LogManager' 之间的模糊引用”。

在 C# 2008 应用程序中,我试图将 nlog 开源日志记录工具添加到已经使用从以下位置获得的 common.logging 的应用程序:http: //netcommon.sourceforge.net

我添加了对 NLog 文件的引用,并将 Nlog 添加到 using 语句中。

问题是这两个工具都使用了一个名为“LogManager”的对象。

因此,您能告诉我如何解决我的问题,以便我可以同时使用这两个 Logmanager。

以下是我在下面列出的代码: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

0 投票
0 回答
531 浏览

asp.net-mvc - 为每个请求调用 ASP.NET MVC 2 + Common.Logging + NLog = Session_Start

在将Common.Logging 2.1.1后面的日志库从 log4net 切换到NLog 2.0后,我的 ASP.NET MVC 2 应用程序保持正确的日志记录,但它开始HttpApplication.Session_Start为每个请求调用该方法。

我正在尝试将 NLog 的File目标与以下配置文件一起使用:

网络配置

NLog.config

我已经尝试过以下方法:

  • 调试应用程序。ASP.NET_SessionIdcookie 被发送到服务器,并且属性Session.SessionID在请求之间没有变化。
  • 切换回 Common.Logging - log4net 以验证问题是否与 Common.Logging - NLog 有关。有用。
  • 省略async="true"NLog 配置文件的 targets 节点中的属性以禁用 NLog 的 AsyncWrapper。它不起作用。
  • 使用其他 NLog 目标,尝试DebuggerDatabase. 有用。

我需要坚持File目标,我想使用 NLog。

0 投票
1 回答
474 浏览

c# - 使用 nLog 和 Common.Logging 在 XAML 设计模式中出错

我收到以下错误:

当我尝试使用DataContext编辑器/选择器时,任何 Window/Usercontrol 属性。我从 NuGet 拉下两个程序集

NLog 配置:

0 投票
1 回答
6711 浏览

c# - 在 C# 中,我的 Common.Logging 记录器应该是实例成员还是静态的?

查看一个使用Common.Logging for .NET 的项目,我注意到一些类将记录器实例声明为类静态成员。例如:

在其他类中,记录器被声明为实例成员:

有理由偏爱一种方法吗?

在哪些情况下推荐每种方法?它与线程安全有关吗?

如果我刚刚声明了一个带有静态“记录器”成员的“记录器”类并且整个项目都使用了它(除了我实际上有一个全局变量的问题),这会不会有问题?

0 投票
2 回答
3086 浏览

c# - Common.Logging 使用 PostSharp 和 NLog 2.0

我使用 Common.Logging 作为 NLog 2.0 的包装器。我这样做是为了将来可以用另一个日志记录提供程序替换 NLog。

我还使用 PostSharp 来避免每次需要时都编写 try catch 块。我有一个继承 OnMethodBoundaryAspect 的类:

我在 web.config 中配置了 Common.Logging,如下所示:

NLog.Config 看起来像这样:

问题是我的表中没有插入任何内容。例如,当我将记录器放入索引页面上的 HomeController 并调用我的 logger.Error("an error") 时,它会在我的表中添加一条记录。

有人可以帮助我吗?

0 投票
1 回答
126 浏览

nservicebus - 为什么 NServiceBus.NHibernate 会导致有关 Common.Logging 参考的 CodeAnalysis 警告?

我有一个配置为 UseNHibernateTimeoutPersister 的 NServiceBus 端点。

我使用 EL 5 进行日志记录:

我还在项目中添加了对 NServiceBus.Core 的引用。

为什么我会收到以下 CodeAnalysis 警告:

警告 36 CA0060:找不到间接引用的程序集“Common.Logging,Version=2.0.0.0,Culture=neutral,PublicKeyToken=af08829b84f0328e”。分析不需要此组件,但分析结果可能不完整。此程序集由:c:\NServicebus3.3.2\NServiceBus.NHibernate.dll 引用。