gpt4 book ai didi

asp.net-core - .Net Core 1.0 的 NLog - 找不到 LayoutRenderer

转载 作者:行者123 更新时间:2023-12-02 02:57:47 25 4
gpt4 key购买 nike

这与this question密切相关,但对于.net Core。我有一个添加 UserId 的自定义布局渲染器,它一直有效,直到我尝试从 project.json 中的“net461”升级到“netcoreapp1.0”。当我这样做时,我必须删除 NLog.Extensions 因为它给了我这个错误:

Package NLog.Extensions 1.0.1 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package NLog.Extensions 1.0.1 supports: net45 (.NETFramework,Version=v4.5)

一切都编译得很好,但在运行时,我在internal-nlog.txt日志文件中收到此错误,当然,它不会影响我的自定义布局渲染器。:

NLog.NLogConfigurationException: Error when setting property 'Layout' on NLog.Targets.DatabaseParameterInfo ---> System.ArgumentException: LayoutRenderer cannot be found: 'aspnet-user-id'

是否有 NLog.Extensions 的替代品,或者我遗漏了什么?

以下是来自project.json的引用:

"NLog.Extensions.Logging": "1.0.0-rtm-alpha4",
"NLog.Web.AspNetCore": "4.2.4" },

我在 Startup.cs 和 NLog.config 中配置的所有内容与更改框架版本之前完全相同。如果发布这些内容有帮助,请告诉我,我会这样做。我很感谢您的帮助。

编辑:添加了project.json内容

"dependencies":{  
"Microsoft.NETCore.App":{
"version":"1.0.1",
"type":"platform"
},
"Microsoft.AspNetCore.Authentication.Cookies":"1.0.0-*",
"Microsoft.AspNetCore.Diagnostics":"1.0.0-*",
"Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore":"1.0.0-*",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore":"1.0.0-*",
"Microsoft.AspNetCore.Mvc":"1.0.0-*",
"Microsoft.AspNetCore.Server.IISIntegration":"1.0.0-*",
"Microsoft.AspNetCore.Server.Kestrel":"1.1.0-preview1-final",
"Microsoft.AspNetCore.StaticFiles":"1.0.0-*",
"Microsoft.EntityFrameworkCore.SqlServer":"1.1.0-preview1-final",
"Microsoft.EntityFrameworkCore.Tools":"1.0.0-*",
"Microsoft.Extensions.Configuration":"1.1.0-preview1-final",
"Microsoft.Extensions.Configuration.EnvironmentVariables":"1.1.0-preview1-final",
"Microsoft.Extensions.Options.ConfigurationExtensions":"1.0.0-*",
"Microsoft.Extensions.Configuration.Json":"1.0.0-*",
"Microsoft.Extensions.Configuration.UserSecrets":"1.0.0-*",
"Microsoft.Extensions.Logging":"1.1.0-preview1-final",
"Microsoft.Extensions.Logging.Console":"1.0.0-*",
"Microsoft.Extensions.Logging.Debug":"1.0.0-*",
"Microsoft.VisualStudio.Web.BrowserLink.Loader":"14.0.0-rc2-final",
"Microsoft.VisualStudio.Web.CodeGenerators.Mvc":{
"version":"1.0.0-*",
"type":"build"
},
"RestSharp.NetCore":"105.2.3",
"Dapper":"1.50.2",
"NLog.Extensions.Logging":"1.0.0-rtm-alpha4",
"NLog.Web.AspNetCore":"4.2.4"
},
"tools":{
"Microsoft.AspNetCore.Razor.Tools":{
"version":"1.0.0-*",
"imports":"portable-net45+win8+dnxcore50"
},
"Microsoft.AspNetCore.Server.IISIntegration.Tools":{
"version":"1.0.0-*",
"imports":"portable-net45+win8+dnxcore50"
},
"Microsoft.EntityFrameworkCore.Tools":{
"version":"1.0.0-*",
"imports":[
"portable-net45+win8+dnxcore50",
"portable-net45+win8"
]
},
"Microsoft.Extensions.SecretManager.Tools":{
"version":"1.0.0-*",
"imports":"portable-net45+win8+dnxcore50"
}
},
"frameworks":{
"netcoreapp1.0":{
"imports":[
"dotnet5.6",
"portable-net45+win8"
]
}
}

最佳答案

假设您使用 this NLog.Extensions package - 它不支持 NETSTANDARD,因此您不能将其与 netcoreapp1.0 一起使用

升级 ASP.NET(到 ASP.NET Core)并非易事,而且该库似乎不再活跃。

幸运的是 NLog.Web.AspNetCore 中有一个 aspnet-user-identity ,您已经将其包含在内。

因此将 ${aspnet-user-id} 替换为 ${aspnet-user-identity}

关于asp.net-core - .Net Core 1.0 的 NLog - 找不到 LayoutRenderer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40684265/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com