log4net from embedded xml?

Posted by sanjeev40084 on Stack Overflow See other posts from Stack Overflow or by sanjeev40084
Published on 2010-04-08T00:31:50Z Indexed on 2010/04/08 0:33 UTC
Read the original article Hit count: 455

Filed under:
|

i have two projects in visual studio. One is the console project while other is regular c# project. In the regular c# project, i have added config file(i.e. Test.config) with log4net section. This file is embedded.

<configSections>
    <section name="log4net"   type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"   />
</configSections>
<log4net>
   <appender name="fileAppender" type="log4net.Appender.RollingFileAppender">
        <file value="log//testapp.log" />
        <appendToFile value="true" />
        <rollingStyle value="Size" />
        <maxSizeRollBackups value="10" />
        <maximumFileSize value="100MB" />
        <staticLogFileName value="true" />
        <layout type="log4net.Layout.PatternLayout,log4net">
            <param name="ConversionPattern" value="%d{ISO8601} [%t] [%-5p] %c - %m%n" />
        </layout>
    </appender>

    <!-- Setup the root category, add the appenders and set the default priority -->
    <root>
        <priority value="ALL" />
        <appender-ref ref="fileAppender" />            
    </root>
</log4net>

Now in my console project, i want to tell my log4net to load log4net information from (Test.config) which is in another project.

This is what i did in the constructor of console project:

Assembly asm = Assembly.GetExecutingAssembly();
Stream xmlStream = asm.GetManifestResourceStream("Northwind.Participant.Config.Test.config");
ILog log = LogManager.GetLogger(typeof(ConsoleStart));

'Northwind.Participant is full namespace. Config - folder where Test.config file is situated.

Does anyone know how i can do that?

© Stack Overflow or respective owner

Related posts about logging

Related posts about c#