简体   繁体   中英

How to include config file in WSP?

I use NLog for logging and now I'm trying to also use it for my SharePoint solution.
How do I instruct WSPBuilder to include NLog.config in WSP and place it in the same folder as solution dll?

EDIT:

Okay, another option is to put it as Web.nlog in SharePoint 80 directory.
Do I need a separate feature for this? What should I write in elements.xml ?

I don't think this can't be done - I assume for security reasons.

DLLs can only be deployed to GAC (signed assemblies only) or to the bin directory of the web application (deployed via the solution manifest, along with any required CAS policies).

If you want extra files alongside the assembly in the bin directory, you'll need to copy them manually.

Does NLog.config need to be a separate file, or can the settings be integrated into the web.config file? If you can integrate the settings into the web.config file, you can add a feature receiver and write the necessary settings during the FeatureActivated or FeatureInstalling event to web.config using SPWebConfigModifications (just google for it). You should also make sure to remove the settings in FeatureDeactivating or FeatureUninstalled event.

You should also take a look here : http://msdn.microsoft.com/en-us/library/ee413935.aspx

I would also ask these questions :

  • Is the configuration the same for all the farm ? Only one web application ?
  • Can you programmaticaly specify NLog configuration ?

Depending on your answers, I will suggest one or more solutions. The disadvantages with the web.config are

  • Configuration is deployed on all SharePoint servers (the feature take care of that, but you have to keep that in mind in case of inconsistant behavior)
  • If you want to modify settings there is no easy way
  • Each time you modify settings, it will recycle application pool.

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