Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use App.config for your log4net configuration without creating a custom logging factory. Simply provide the App.config file as an argument to the <code>LoggingFacility</code> constructor:</p> <pre class="lang-cs prettyprint-override"><code>container .AddFacility("logging", new LoggingFacility(LoggerImplementation.Log4net, System.AppDomain.CurrentDomain.SetupInformation.ConfigurationFile) ) </code></pre> <p>Unlike Mauricio Scheffer's answer, the default factory does <code>ConfigureAndWatch</code>. This works just fine for me with the App.config file, though I'm not running on IIS or anything else that restricts permissions.</p> <p>I'm doing this in code because you can't reliably use the Windsor Xml configuration to load log4net configuration from App.config. This is because the location of App.config can be modified when creating a new <code>AppDomain</code>.</p> <p>Using my solution means the log file configuration will be compiled into your code. But you can mitigate this by using a Windsor Installer to configure logging, and specify the installer (or installer assembly) from the App.config file:</p> <pre class="lang-cs prettyprint-override"><code>public class LoggingInstaller : IWindsorInstaller { public void Install(IWindsorContainer container, IConfigurationStore store) { container .AddFacility("logging", new LoggingFacility(LoggerImplementation.Log4net, System.AppDomain.CurrentDomain.SetupInformation.ConfigurationFile) ); } } </code></pre> <p>...</p> <pre class="lang-xml prettyprint-override"><code>&lt;castle&gt; &lt;installers&gt; &lt;install assembly="MyAssemblyName" /&gt; &lt;/installers&gt; &lt;/castle&gt; </code></pre> <p>If in the future (maybe in your test cases) you have to load the logging configuration from a different file, and can't or don't want to recompile, simply change the Xml to point to Windsor Installers in a different assembly:</p> <pre class="lang-xml prettyprint-override"><code>&lt;castle&gt; &lt;installers&gt; &lt;install assembly="SomeOtherAssemblyName" /&gt; &lt;/installers&gt; &lt;/castle&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload