log4net%属性不起作用

时间:2015-05-14 13:33:31

标签: c# .net logging log4net log4net-configuration

我有一个小测试项目,代码如下:

<input type="text">
<input type="text">

我的 log4net.xml 配置文件包含以下内容:

$script = <<<EOF
<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "LodgingReservation",
  "reservationNumber": "abc456",
  "reservationStatus": "http://schema.org/Confirmed",
  "underName": {
    "@type": "Person",
    "name": "John Smith"
  },
  "reservationFor": {
    "@type": "LodgingBusiness",
    "name": "Hilton San Francisco Union Square",
    "address": {
      "@type": "PostalAddress",
      "streetAddress": "333 O'Farrell St",
      "addressLocality": "San Francisco",
      "addressRegion": "CA",
      "postalCode": "94102",
      "addressCountry": "US"
    },
    "telephone": "415-771-1400"
  },
  "checkinDate": "2017-04-11T16:00:00-08:00",
  "checkoutDate": "2017-04-13T11:00:00-08:00"
}
</script>
EOF;

$body = '<div>my email content</div>' . $script;

我的问题是为什么log4net会创建名称为%property {logFileName} 的文件,并且不能用 log.txt 替换它?

log4net 库取自NuGet(Id:log4net Version:2.0.3)。

1 个答案:

答案 0 :(得分:9)

请在xml配置中使用此功能

<file type="log4net.Util.PatternString" value=".\%property{logFileName}" />