Questions tagged [system.diagnostics]

System.Diagnostics is a namespace of the .NET framework. It provides classes that allow you to interact with system processes, event logs, and performance counters.

System.Diagnostics is a namespace of the .NET framework. It provides classes that allow you to interact with system processes, event logs, and performance counters.

References

670 questions
21
votes
2 answers

Mac OSX: Using dtruss?

I'm trying to dtruss a process in Mac OSX Catalina, however dtrace is reporting an error. $ sudo dtruss whoami dtrace: system integrity protection is on, some features will not be available dtrace: failed to execute whoami:…
user9405153
21
votes
2 answers

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

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…
wageoghe
  • 27,390
  • 13
  • 88
  • 116
20
votes
3 answers

Is my process waiting for input?

I am using the Process class to run an exe. The exe is a 3rd party console application that I do not control. I wish to know whether the process is waiting for input on the command line. Should it make any difference, I intend to kill the…
Don Vince
  • 1,282
  • 3
  • 18
  • 28
18
votes
4 answers

System.Diagnostics.Debug namespace vs Other logging solutions (log4net, MS Enterprise Library, etc.)

I'm currently investigating various logging possibilities for .net projects and I can't decide between System.Diagnostics.Debug/Trace features and third party libraries like log4net, MS Enterprise Library, NLog, etc. At the moment I have found out…
timurso
  • 273
  • 2
  • 6
18
votes
2 answers

How get value of parameters in stacktrace

I can get information about a parameter by StackTrace using something like this: catch (Exception ex) { var st = new StackTrace(ex); System.Reflection.ParameterInfo pi = st.GetFrame(0).GetMethod().GetParameters().First(); } I want know how…
Jonny Piazzi
  • 3,684
  • 4
  • 34
  • 81
17
votes
2 answers

How to get the current TraceId and SpanId

This article, https://devblogs.microsoft.com/aspnet/improvements-in-net-core-3-0-for-troubleshooting-and-monitoring-distributed-apps/, tells me that the field TraceId is available as a correlation id, which is great! info:…
Sigurd Garshol
  • 1,376
  • 3
  • 15
  • 36
17
votes
4 answers

C#: Redirect Standard Output of a Process that is Already Running

I've been having a hard time getting the output of a "sub-process" (one launched internally by a blackbox process that I'm monitoring via c# System.Diagnostics.Process) I took the advice given by the answer of my previous post: here. And there you…
Lonnie Best
  • 9,936
  • 10
  • 57
  • 97
16
votes
4 answers

.net Diagnostics best practices?

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…
mamu
  • 12,184
  • 19
  • 69
  • 92
16
votes
3 answers

What is the best way to log exceptions using ETW?

Is there a standard way to log exceptions using ETW? As far as I have seen the only way to do this is to log the message and possibly the inner exception message as there is not strongly typed parameter for the Exception type.
jaffa
  • 26,770
  • 50
  • 178
  • 289
15
votes
5 answers

How to execute process on remote machine, in C#

How can I start a process on a remote computer in c#, say computer name = "someComputer", using System.Diagnostics.Process class? I created a small console app on that remote computer that just writes "Hello world" to a txt file, and I would like to…
DJPB
  • 5,429
  • 8
  • 30
  • 44
14
votes
4 answers

How to keeps colours from msbuild output?

When I run msbuild at the command line it shows pretty colours in the console. However when I run it from C# with Process.Start, the output appears in black and white. How can I keep the colours? var info = new ProcessStartInfo("msbuild") { …
Colonel Panic
  • 132,665
  • 89
  • 401
  • 465
14
votes
2 answers

Why is this process crashing as soon as it is launched?

We have an IIS WCF service that launches another process (app.exe) as a different user. I have complete control over both applications (and this is a dev environment for now). The IIS app pool runs as me, a domain user (DOMAIN\nirvin), who is also a…
nateirvin
  • 1,173
  • 1
  • 10
  • 28
14
votes
3 answers

Automatically log System.diagnostics.trace messages to an Nlog target

Say you have C# trace messages all over an application. Something like: Trace.TraceInformation("Service Started"); How do you automatically log this to an nLog target without having to add code like the following to all the classes that…
Solracnapod
  • 843
  • 3
  • 13
  • 23
13
votes
2 answers

Get CPU and RAM usage

I need to get the ram memory and CPU usage during execution of a process (the process can run sometimes and over 30 minutes). I am able to get the free RAM but the CPU usage it's not correct, compared with the value from task manager. Am I doing…
Buda Gavril
  • 21,409
  • 40
  • 127
  • 196
12
votes
4 answers

How to trace all HTTP requests in .net core 2.1 globally?

I want to log all HTTP requests in a dotnet core 2.1 application. Logging should include HTTP headers, body and the host address. I need to bind my logging code globally without changing the existing code. I tried this example…
cengaver
  • 302
  • 1
  • 2
  • 13
1
2
3
44 45