Log4net doesn't write to file

后端 未结 4 1559
误落风尘
误落风尘 2020-12-17 20:28

I want add new log to file.this is my appender:



        
4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-17 20:55

    You need to initialise the logging as the very first step in your app, and from the same assembly that you have the [assembly] tag:

    From the docs:

    Therefore if you use configuration attributes you must invoke log4net to allow it to read the attributes. A simple call to LogManager.GetLogger will cause the attributes on the calling assembly to be read and processed. Therefore it is imperative to make a logging call as early as possible during the application start-up, and certainly before any external assemblies have been loaded and invoked.

    Add something like this in your start up code:

    LogManager.GetLogger("Initialises logging from assembly attributes");
    

提交回复
热议问题