开发者

nlog not working for class library project

I have an MVC application that uses a couple of class library projects. I have implemented NLog for logging across all the projects. Each project (including the class library projects) have the NLog.config file. Logging works great for the MVC application, ho开发者_运维知识库wever for the other class libraries the log files do not get generated at all.

Am I doing something wrong here? I have set log files to be generated at a hardcoded path (D:{project_name}\xx) for all the projects.

Also, I have ensured that all the "NLog.config" files are set to "Copy Always" to the output directory.


Generally speaking, my understanding is that only one config file is used by the entire application. So, each class library will be using the app's config file, not the config file that you created for each class library. I think that there are ways that you can force a class library to look for its own config file, but that is not as common as just accessing the app's config file. I'm not sure that would even work in the case of NLog, since there is only one "NLog instance" (probably not the most accurate terminology). Because there is only one "NLog", it can be configured only one way.

Is there a reason why you didn't (or don't want to) put all of the NLog config information in the same file?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜