Log4Net and GAC - How to reference Configuration Files?

前端 未结 2 649
日久生厌
日久生厌 2021-01-28 03:06

I am using log4net during my development, as as part of a project constraint, I now need to add it to the Global Assembly Cache.

The logging definitions are in a file Lo

2条回答
  •  清歌不尽
    2021-01-28 04:02

    log4net expects the config file to be in the path returned by:

     System.AppDomain.CurrentDomain.BaseDirectory
    

    Let your application print this information to some file and then you know where you need to place the config file.

    Of course there are other solutions, but then you cannot use the attribute anymore. Calling the ConfigureAndWatch() method directly allows you to figure out yourself where the config file is; you can even decide on a location (does not have to be a hard-coded path).

提交回复
热议问题