AspNet Core Log4Net 代理系统日志

AspNet Core Log4Net Proxy Syslog

我在网络核心应用程序中使用 log4net。但我不知道如何通过 http 代理发送日志。我的项目中有一个 Remote syslog appender。

任何 advice/direction 如何设置代理将不胜感激。

    public class Program
{
    private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
    public static void Main(string[] args)
    {
        var webProxy = new WebProxy("http://my.proxy.com:8080");
        webProxy.UseDefaultCredentials = true;

        var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());
        XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));
        log.Info("TEST");
    }
}

log4net.config

<log4net>
    <appender name="PapertrailRemoteSyslogAppender" type="log4net.Appender.RemoteSyslogAppender">
        <facility value="Local6" />
        <identity value="%date{yyyy-MM-ddTHH:mm:ss.ffffffzzz} %P{log4net:HostName} MYSUPERAPP" />
        <layout type="log4net.Layout.PatternLayout" value="%level - %message%newline" />
        <remoteAddress value="logs123.papertrailapp.com" />
        <remotePort value="123456" />
    </appender>
    <root>
        <level value="INFO" />
        <appender-ref ref="PapertrailRemoteSyslogAppender" />
    </root>
</log4net>

csproj:

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <AssemblyName>MySuperApp</AssemblyName>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="log4net" Version="2.0.8" />
  </ItemGroup>
  <ItemGroup>
    <Content Update="log4net.config">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
  </ItemGroup>
</Project>

尝试使用此配置

<appender name="UdpAppender" type="log4net.Appender.UdpAppender">
      <param name="RemoteAddress" value="127.0.0.1" />
      <param name="RemotePort" value="514" />
      <layout type="log4net.Layout.PatternLayout, log4net">
        <conversionPattern value="%-5level %logger [%property{NDC}] - %message%newline" />
      </layout>
</appender>