Sitecore CMS and everything related RSS 2.0
 Wednesday, October 04, 2006

Sitecore 5.3 introduces some notable configuration enhancements: ability to include separate configuration files and variable declaration.

Variables

“sc.variable” directive is used to declare a variable which can be referenced in other branches of configuration hierarchy.

In 5.1 / 5.2 it’s only possible to refer to parent attributes:

<parent parent_attribute=”parent_value”>
  <child childattribute=”$(parent_value)” />
</parent>

// can’t use $(parent_attribute) here

5.3 supports and uses this:

<sc.variable name="dataFolder" value="/data" />

<settings>
  <setting name="LicenseFile" value="$(dataFolder)/license.xml" />
</settings>

So finally, when moving data folder to a different location only one variable declaration has to be updated. Interestingly enough, Sitecore log4net appender knows about $dataFolder variable as well:

<appender name="LogFileAppender" type="log4net.Appender.SitecoreLogFileAppender, Sitecore.Logging">
<file value="$(dataFolder)/logs/log.{date}.txt" />

Includes

Using the “sc:include” directive, you can include another configuration file on the spot.

Example:

<connections serverMode="File">
  <sc.include file="/App_Config/$(database)/$(serverMode)Connections.config" />
  <sc.include file="/App_config/$(database)/Timeouts.config"/>
</connections>

The included file must be a valid xml document with document element root node:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <nodes that should be included go here />
</configuration>

The example demonstrates a powerful idea of combining includes with variables/attributes: by having dynamic values as a part of include file path, you can swap larger sections of configuration file based on one master setting.

Tricks

Both includes and variables support nesting:

  • Configuration file that is being included can contain include directives as well
  • Configuration file that is being included can declare variables used in the parent file

Variables can be defined more than once – the last declaration wins, as long as they are defined in one configuration file. It’s not possible to re-declare variable already declared in included configuration file.

Watchers

Yet another good thing is new configuration watchers. Since we don’t store all settings in web.config now, changes to files in \App_config folder will not result in automatic application restart.

Instead, changes to main configuration files will be effective immediately: change /App_Config/commands.config and use new commands without restart.

Wednesday, October 04, 2006 5:31:27 PM (FLE Standard Time, UTC+02:00)  #    Comments [2]

Archive
<October 2006>
SunMonTueWedThuFriSat
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234
Blogroll
 Alex de Groot
Few words about SiteCore from Holland
 Alexander Shyba
Sitecore Support
 Anders Dreyer
Anders Dreyer on Sitecore Development
 Jakob Christensen
Sitecore Core Development
 Lars Fløe Nielsen
Lars's ramblings about development and business processes
 Ole Thrane
Sitecore API
 Runi Thomsen
Runi Thomsen Sitecore Toughts
 The Sitecore Experience
The Sitecore Experience
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010
Alexey Rusakov
Sign In
Statistics
Total Posts: 211
This Year: 0
This Month: 0
This Week: 0
Comments: 0
Themes
Pick a theme:
All Content © 2010, Alexey Rusakov
DasBlog theme 'Business' created by Christoph De Baene (delarou)