Log not generating in multi process

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Log not generating in multi process

Sanjoy Jana
This post has NOT been accepted by the mailing list yet.
Hi All,

I am using log4net for the first time. I am facing a problem as follows:

I have a console application which uses log4net for logging. I have another WinFrom application which is not using log4net. Now, I need to call the console application from the WinFrom application on a separate process using following code snippet:

                Process process = new Process();
                // Configure the process using the StartInfo properties.
                process.StartInfo.FileName = processname;
                process.StartInfo.Arguments = Args;
                process.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
                //process.StartInfo.UseShellExecute = true;
                process.Start();
                process.WaitForExit();// Waits here for the process to exit.

Now, when the console exe is running in stand-alone mode from command prompt, it is generating log as expected, but when calling from Winfrom application, it is not generating the log. Following is the log4net setting I am using in app.config file of console application:

<log4net>
        <appender name="XYZLogAppender" type="log4net.Appender.RollingFileAppender">
                <file type="log4net.Util.PatternString" value="%property{LogPath}/%property{LogFileName}-%date{MM-dd-yyyy}.log" />
                <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
                <appendToFile value="true" />
                <rollingStyle value="Size" />
                <maxSizeRollBackups value="7" />
                <maximumFileSize value="4MB" />
                <staticLogFileName value="true" />
                <layout type="log4net.Layout.PatternLayout">
                       
                </layout>
        </appender>
  <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
   
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%d [%t] %-5p %c.%M():%L - %m%n" />
    </layout>
  </appender>
  <logger name="XYZ.Console">
    <appender-ref ref="XYZLogAppender" />
    <appender-ref ref="ConsoleAppender" />
  </logger>
  <root>
                <level value="ALL" />
                <appender-ref ref="AbacusPCRLogAppender" />
        </root>
</log4net>

Am I missing something? Any help in this matter is highly appreciated.

Thanks in advance.

Sanjoy Jana.