how do you make log4net output to current working directory?

后端 未结 2 1738
温柔的废话
温柔的废话 2021-02-20 06:58

Is it possible to have log4net put its log files relative to the current working directory instead of the directory where the application resides?

In other words, if I

2条回答
  •  终归单人心
    2021-02-20 07:21

    I ended up looking at the log4net source and determined I can implement my own appender that extends FileAppender and overrides the File property.

    class CWDFileAppender : FileAppender
    {
        public override string File
        {
            set
            {
                base.File = Path.Combine(Directory.GetCurrentDirectory(), value);
            }
        }
    }
    

    I just use CWDFileAppender in my configuration.

提交回复
热议问题