log4net doesn't log in myProcess.OutputDataReceived
C#
1
Posts
1
Posters
0
Views
1
Watching
-
Hi, my app logs correctly while code is beeing executed within my method
DoIt
. But it doesn't log in theProcess.OutputDataReceived
's EventHandler even ifp_OutputDataReceived
is called. Is there anything I need to look at while usingProcess
?private void DoIt(string arguments) { \_log.Fatal("TEST"); // DOES LOG Process p = new Process(); p.StartInfo.FileName = @"D:\\vssTOOLS\\NetJobs\\UpdateDealArchiveInstrSeq\\UpdateCaller\\bin\\Debug\\UpdateDealArchiveInstrSeq.exe"; p.StartInfo.RedirectStandardError = true; p.StartInfo.RedirectStandardOutput = true; p.OutputDataReceived += new DataReceivedEventHandler(p\_OutputDataReceived); p.ErrorDataReceived += new DataReceivedEventHandler(p\_ErrorDataReceived); p.StartInfo.WorkingDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(typeof(Caller)).Location); p.StartInfo.UseShellExecute = false; p.StartInfo.Arguments = arguments; p.Start(); p.BeginOutputReadLine(); p.BeginErrorReadLine(); p.WaitForExit(); //Synchronisieren do { System.Threading.Thread.Sleep(100); } while (!p.HasExited); if (p.ExitCode != 0) { // DOES LOG for (int i = 0; i < procOut.ToString().Length; i += 2000) \_log.Info(procOut.ToString().Length > i + 2000 ? procOut.ToString().Substring(i, 2000) : procOut.ToString().Substring(i)); for (int i = 0; i < procErr.ToString().Length; i += 2000) \_log.Error(procErr.ToString().Length > i + 2000 ? procErr.ToString().Substring(i, 2000) : procErr.ToString().Substring(i)); throw new ApplicationException("Es ist ein Fehler aufgetreten: " + procErr.ToString()); } } StringBuilder procOut = new StringBuilder(); StringBuilder procErr = new StringBuilder(); void p\_ErrorDataReceived(object sender, DataReceivedEventArgs e) { procErr.AppendLine(e.Data); \_log.Error(e.Data); // DOES NOT LOG } void p\_OutputDataReceived(object sender, DataReceivedEventArgs e) { procOut.AppendLine(e.Data); \_log.Info(e.Data); // DOES NOT LOG }