PayPal的特定log4net-logfile

时间:2015-05-07 10:29:46

标签: c# paypal log4net log4net-configuration

是否可以在App.config中指定日志文件?

我在.NET中找到了这些参数: https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters

在PHP中,它似乎是可能的(Logging): https://github.com/paypal/sdk-core-php/wiki/Configuring-the-SDK

现在,信息将保存在许多声明的日志文件的第一个中。

1 个答案:

答案 0 :(得分:3)

是的,可以在配置中指定日志文件。 PayPal .NET SDK wiki显示您需要添加到配置文件中的信息:

<configuration>
  <configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
  </configSections>

  <!-- log4net settings -->
  <log4net>
    <appender name="FileAppender" type="log4net.Appender.FileAppender">
      <file value="my_app.log"/>
      <appendToFile value="true"/>
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] %message%newline"/>
      </layout>
    </appender>
    <root>
      <level value="DEBUG"/>
      <appender-ref ref="FileAppender"/>
    </root>
  </log4net>

  <!-- 
  App-specific settings. Here we specify which PayPal logging classes are enabled.
    PayPal.Log.Log4netLogger: Provides base log4net logging functionality
    PayPal.Log.DiagnosticsLogger: Provides more thorough logging of system diagnostic information and tracing code execution
  -->
  <appSettings>
    <!-- Diagnostics logging is only available in a Full Trust environment. -->
    <!-- <add key="PayPalLogger" value="PayPal.Log.DiagnosticsLogger, PayPal.Log.Log4netLogger"/> -->
    <add key="PayPalLogger" value="PayPal.Log.Log4netLogger"/>
  </appSettings>
</configuration>

my_app.log替换为您自己的日志文件名。