简体   繁体   中英

log4net compact framework 3.5 No app.config to add file appenders

I am developing a log4net using CF 3.5 VS 2008 on windows mobile 6.

I have used log4net before in my windows xp applications, and I always put the configuration in the app.config file.

However, this is my first time using log4net with CF3.5. And I have noticed there is no app.config file, and when I try to add a new item there is no template for one. Am I missing something here?

If 3.5 doesn't have a app.config file. Where can I put my log4net configuration? I would like to log4net using the file appender and save the log in the directory where the application is executing from.

Many thanks for any suggestions,

Compact framework does not support app.config files but you can emulate such behavior.

Create a xml with setting and then read content of that file.

I found this workaround that work for me:

http://www.eggheadcafe.com/articles/dotnetcompactframework_app_config.asp

This reaction is a bit late, and probably you have solved it already. However there might be some other users that have the same problem.

You can also specify that you want to use a different config-file using the XmlConfiguratorAttribute. See here . For instance you could specify the log4net-configuration in 'log4net.config' which is in your bin-directory and add in the assemblyInfo.cs:

[assembly: log4net.Config.XmlConfigurator(ConfigFile="log4net.config",Watch=true)]

Ruben, This won't work because XmlConfiguratorAttribute is not available from log4net to compact framework.

Instead, you can use XmlConfigurator.Configure("filename.config") replacing filename.config by the path to your log4net configuration file.

I've put this on the main program class of a Windows Application on my mobile application.

Hugs :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM