小编Boo*_*ser的帖子

为什么私有变量定义上有问号?

我正在阅读一篇关于MVVP模式的文章以及如何使用WPF实现它.在源代码中有多行,我无法弄清楚它中的问号是什么.

private DateTime? _value;
Run Code Online (Sandbox Code Playgroud)

?定义中的含义是什么?我试图在VS的帮助下找到它,但失败了.

c# nullable

23
推荐指数
4
解决办法
2万
查看次数

使用Castle.Facilities.Logging和log4net进行日志记录

我正在努力让Castle Windsor的log4net集成工作.我用类型的公共属性编写了我的类,ILogger并在我的app.config中进行了配置,如下所示.

<configuration>
  <configsections>
    <section name="castle" type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler, Castle.Windsor" />
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
  </configsections>

  <castle>
    <facilities>
      <facility id="logging" type="Castle.Facilities.Logging.LoggingFacility, Castle.Facilities.Logging" loggingApi="log4net" />
    </facilities>
    <components>
      <component id="form1" type="WinFormsActiveRecordSample.Form1, WinFormsActiveRecordSample" />
    </components>
  </castle>
  <log4net>
    <root>
      <level value="ALL" />
      <appender-ref ref="FileAppender" />
    </root>
    <appender name="FileAppender" type="log4net.Appender.FileAppender">
      <file value="main.log" />
      <appendToFile value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date{dd.MM.yy HH:mm:ss} %-5level %logger - %message%newline" />
      </layout>
    </appender>
  </log4net>
</configuration>
Run Code Online (Sandbox Code Playgroud)

在我看来,这应该是有效的,但事实并非如此.当我loggingApi="console"正确设置日志时.当我将其更改为log4net时,它什么也没做.log4net配置来自块正在运行的另一个项目.我该怎么做才能使用日志文件?必须有特殊的log4net配置吗?

谢谢你的任何提示

鲍里斯

logging log4net castle-windsor log4net-configuration

9
推荐指数
2
解决办法
1万
查看次数