C# 带有seq的Serilog在windows 4.6.2上发布后找不到System.Net.Http
因此,我很难让应用程序在经过发布过程后运行。它们通过visual Studio调试器工作,因为System.Net.hhtp的一个版本被放入调试目录中。我相信这个dll是加密的并存储在客户机上,这就是为什么它不在输出中,我不明白的是我做错了什么 **:我想指出的是,我在linux上为dotnetcore设置这个,然后发布和运行它没有问题 下面是我制作的一个简单cli应用程序,用于显示和隔离我的问题:C# 带有seq的Serilog在windows 4.6.2上发布后找不到System.Net.Http,c#,logging,serilog,C#,Logging,Serilog,因此,我很难让应用程序在经过发布过程后运行。它们通过visual Studio调试器工作,因为System.Net.hhtp的一个版本被放入调试目录中。我相信这个dll是加密的并存储在客户机上,这就是为什么它不在输出中,我不明白的是我做错了什么 **:我想指出的是,我在linux上为dotnetcore设置这个,然后发布和运行它没有问题 下面是我制作的一个简单cli应用程序,用于显示和隔离我的问题: using Serilog; using Serilog.Events; using Syste
using Serilog;
using Serilog.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SerilogTest
{
class Program
{
static void Main(string[] args)
{
SetStaticLoggerConfiguration("http://localhost:5341/", @"C:\Logs\IQLRServices\JobDispatcher-{Date}.txt");
Log.Information("The logger is working.");
}
private static void SetStaticLoggerConfiguration(string seqAddress = null, string rollingFileFormat = null)
{
LoggerConfiguration logConfig = new LoggerConfiguration();
if (!string.IsNullOrWhiteSpace(seqAddress))
{
logConfig.WriteTo.Seq(seqAddress, Serilog.Events.LogEventLevel.Verbose, 2500, TimeSpan.FromSeconds(10));
}
if (!string.IsNullOrWhiteSpace(rollingFileFormat))
{
logConfig.WriteTo.RollingFile(rollingFileFormat,
restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Debug,
outputTemplate: "{Timestamp:MM-dd-yyyy HH:mm:ss.fff zzz} [{Level}] {Scope} {Properties} {Message} {NewLine}{Exception}");
}
if (Environment.UserInteractive)
{
logConfig.WriteTo.Console(LogEventLevel.Verbose);
}
var log = logConfig.CreateLogger();
Log.Logger = log;
Serilog.Debugging.SelfLog.Enable(msg => Log.Error("Serilog internal error: {@ErrorMessage}", msg));
}
}
}
以下是我为了编译而添加的Nuget依赖项(我添加了Serilog.Sinks.Seq包,它有自己的DEP,然后添加了Serilog.Sinks.Console):
您需要将以下内容添加到项目的
CSPROJ
文件中:
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>
真的
真的
您需要将以下内容添加到项目的CSPROJ
文件中:
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>
真的
真的
似乎没有任何改变。我有第一个在那里,但是第二个没有改变任何东西。似乎没有改变任何东西。我有第一个,但第二个没有改变任何东西。切换回log4net for windows。此问题在多台同事计算机上重现,未找到修复程序。这似乎与实际项目有关,目标framework 4.5+在C:\Program Files(x86)中有对System.Net.Http的本地引用\参考Assemblies\Microsoft\Framework\.NETFramework\v4.X\System.Net.Http.dll。结果:这导致nuget软件包版本和框架版本之间发生冲突…切换回log4net for windows。此问题在多台同事计算机上重现,未找到修复程序。这似乎与目标framework 4.5+具有位于中的System.Net.Http的本地引用的实际项目有关C:\Program Files(x86)\Reference Assembly\Microsoft\Framework\.NETFramework\v4.X\System.Net.Http.dll。结果:导致nuget包版本和框架版本之间发生冲突。。。
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>