Using NLog v4.4.12, I have this in my App.config
<nlog>
<include file="..\Common\Logs\Variables.xml" />
<rules>
<logger name="*" minlevel="${logLevel}" writeTo="LogFile, Wcf"/>
</rules>
</nlog>
And here is my Variables.xml file content
<?xml version="1.0" encoding="utf-8"?>
<nlog autoReload="true">
<variable name="logLevel" value="Fatal" />
</nlog>
But I get an Exception when launching my app
Unknown log level: ${logLevel}
Am I doing something wrong or is it just impossible?
The goal of this is to eventually have an xml file per project that need to log things so each project can have his own minlevel and be able to change it at runtime via the edition of this xml.
Edit: Adding this code just before the Exception is thrown shows that my variable is there with the desired value.
var nl = NLog.LogManager.Configuration;
if (nl != null)
{
if (nl.Variables.ContainsKey("logLevel"))
{
Console.WriteLine(nl.Variables["logLevel"]);
}
}