开发者

How to get WinForms app to find a log4net config file when running from the IDE?

开发者 https://www.devze.com 2023-01-12 00:53 出处:网络
I\'m using log4net with a VisualStudio WinForms app, and I need log4net to find its config file. (I must keep the config settings in a separate file.)

I'm using log4net with a VisualStudio WinForms app, and I need log4net to find its config file. (I must keep the config settings in a separate file.)

It works if the config file is in 开发者_如何转开发the directory with the executable, but how do I get it there? For now I've added a post-build action:

copy "$(ProjectDir)test.log4net.xml" "$(TargetDir)"

But isn't there a better way? For such a simple task this seems like an awful kludge.

It's only a problem in development, because at deployment I can install the file with the executable. I'm using VS 2010, if that matters.


I "include" the configuration file so that it's visible in the Solution Explorer, and then in the file's properties in Visual Studio, set "Copy to Output Directory" = "Copy Always".

0

精彩评论

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