system.diagnostics

WCF logging/tracing and activity id propagation using log4net or NLog

跟風遠走 提交于 2019-12-03 05:46:03
问题 I have seen many other questions on logging. Best practices. What logging platform is best. Etc. Here are some links from here on SO with very good discussions on the topic: logging best practices log4net vs TraceSource best logging solution for .NET 3.5 project .NET 3.5 logging BEGIN EDIT: Having typed this long post, I guess that the main thing that I am trying to figure out is how tightly coupled WCF logging/tracing and activity id propagation are to System.Diagnostics and TraceSources.

.net Diagnostics best practices?

给你一囗甜甜゛ 提交于 2019-12-03 01:43:49
问题 We initially didn't use any logging or debug tracing but after spending few weeks to trace down some data corruption we decided to put required Debug.Write and Trace for production and Debug.Assert So now question is What is the best practice to use debug and trace logging. I am just looking for some thing generic. public void AddRectodatabase(object record) { Debug.WriteLine(record.ToString()); Trace.WriteLine(record.ToString()); // Add it to databse Debug.Assert(true, "Use this on case by

.net Diagnostics best practices?

时光怂恿深爱的人放手 提交于 2019-12-02 15:17:59
We initially didn't use any logging or debug tracing but after spending few weeks to trace down some data corruption we decided to put required Debug.Write and Trace for production and Debug.Assert So now question is What is the best practice to use debug and trace logging. I am just looking for some thing generic. public void AddRectodatabase(object record) { Debug.WriteLine(record.ToString()); Trace.WriteLine(record.ToString()); // Add it to databse Debug.Assert(true, "Use this on case by case basis"); } Is this good enough for general purpose, am i doing anything wrong in there? We want to

.NET How to check if a Windows process is running as an “App” or as a “Background application”

自作多情 提交于 2019-12-02 06:28:02
On Windows 8.1 you go into the task manager and check the list of processes, there are two lists: - One for "Apps", which are visible foreground apps - One for "Background processes", which are processes running in the background My end goal is to time how long it takes an application to load. When the application is still loading, it appears in "Background processes". However, once loaded, it appears in "Apps". This is going to be my criteria on what constitutes an app finishing loading. I am using a System.Diagnostics.Process object to try to accomplish this. However, I am struggling to come

Add Trace methods to System.Diagnostics.TraceListener

我们两清 提交于 2019-12-02 01:59:43
问题 I wrote a Log class derived from System.Diagnostics.TraceListener like so public class Log : TraceListener This acts as a wrapper to Log4Net and allows people to use System.Diagnostics Tracing like so Trace.Listeners.Clear(); Trace.Listeners.Add(new Log("MyProgram")); Trace.TraceInformation("Program Starting"); There is a request to add additional tracing levels then the default Trace ones (Error,Warning,Information) I want to have this added to the System.Diagnostics.Trace so it can be used

EventSource .net 4.0 GenerateManifest

♀尐吖头ヾ 提交于 2019-12-01 21:49:46
I've been trying to work with ETW in .net 4.0. I have started using Microsoft EventSource Library 1.0.4-beta ( https://www.nuget.org/packages/Microsoft.Diagnostics.Tracing.EventSource ) Here is the code i written for generating events for my application. [EventSource(Name = "Samples-EventSourceDemos-EventSourceLogger")] public sealed class EventSourceLogger : EventSource { public static EventSourceLogger Log = new EventSourceLogger(); public static string GetManifest() { return GenerateManifest(typeof(EventSourceLogger), null); } [Event(200, Level = Microsoft.Diagnostics.Tracing.EventLevel

“File not found” error launching system32\\winsat.exe using Process.Start()

戏子无情 提交于 2019-12-01 17:37:40
I'm trying to run the Windows System Assessment Tool (winsat.exe) using the following code: System.Diagnostics.Process WinSPro = new System.Diagnostics.Process(); System.Diagnostics.ProcessStartInfo WinSSInfo = new System.Diagnostics.ProcessStartInfo(); WinSSInfo.FileName = "cmd.exe"; WinSSInfo.Arguments = "/k winsat.exe"; WinSPro.StartInfo = WinSSInfo; WinSPro.Start(); This code works if I only call cmd.exe, and even if I call regedit.exe it still works. However, when I try to call winsat.exe as a argument of cmd.exe, it fails. The command prompt shows this: 'winsat.exe' is not recognized as

“File not found” error launching system32\winsat.exe using Process.Start()

廉价感情. 提交于 2019-12-01 16:34:17
问题 I'm trying to run the Windows System Assessment Tool (winsat.exe) using the following code: System.Diagnostics.Process WinSPro = new System.Diagnostics.Process(); System.Diagnostics.ProcessStartInfo WinSSInfo = new System.Diagnostics.ProcessStartInfo(); WinSSInfo.FileName = "cmd.exe"; WinSSInfo.Arguments = "/k winsat.exe"; WinSPro.StartInfo = WinSSInfo; WinSPro.Start(); This code works if I only call cmd.exe, and even if I call regedit.exe it still works. However, when I try to call winsat

How can I get the current Trace Switch programatically?

别说谁变了你拦得住时间么 提交于 2019-12-01 16:32:59
In my web.config I have: <system.diagnostics> <switches> <add name="logLevelSwitch" value="1" /> </switches> </system.diagnostics> Is there a way that I could call, for example: System.Diagnostics.TraceSwitch["logLevelSwitch"] to get the current value? Once you've defined the switch value in your web.config file, it's easy to get this value from your application by creating a TraceSwitch with the same name: private static TraceSwitch logSwitch = new TraceSwitch("logLevelSwitch", "This is your logLevelSwitch in the config file"); public static void Main(string[] args) { // you can get its

How can I get the current Trace Switch programatically?

风流意气都作罢 提交于 2019-12-01 15:56:06
问题 In my web.config I have: <system.diagnostics> <switches> <add name="logLevelSwitch" value="1" /> </switches> </system.diagnostics> Is there a way that I could call, for example: System.Diagnostics.TraceSwitch["logLevelSwitch"] to get the current value? 回答1: Once you've defined the switch value in your web.config file, it's easy to get this value from your application by creating a TraceSwitch with the same name: private static TraceSwitch logSwitch = new TraceSwitch("logLevelSwitch", "This is