Log4Net can't find %username property when I name the file in my appender

前端 未结 5 1299
滥情空心
滥情空心 2020-12-19 10:48

log4net doesn\'t do the correct PatternString substitution for my login name. I want my log to be

Logs\\YYYYMMDD\\MSMQcore_[username].lo

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-19 11:27

    Just one improvement to the Kit's solution: Use attribute

    [TypeConverter("namespace.ConfigurationSettingsPatternStringConverter")]
    public class ConfigurationSettingsPatternString : PatternString
    {
    

    And the call to

    ConverterRegistry.AddConverter(
    // type we want to convert to (from string)...
    typeof(ConfigurationSettingsPatternString),
    // the type of the type converter that will do the conversion...
    typeof(ConfigurationSettingsPatternStringConverter));
    

    is no longer required.

提交回复
热议问题