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
5
votes
1 answer

What is the difference between "switch" and "filter" in Tracing in .NET?

What is the difference between "switch" and "filter" in Tracing in .NET ? They seem to work in similar way.
Brij
  • 11,731
  • 22
  • 78
  • 116
5
votes
1 answer

Trace Class - How to set Autoflush by code

I would like to set the AutoFlush attribute to true, but I need to do it by code. Programmatically. I have found this how to configure the trace element and also the AutoFlush property of the Trace Class. Then I have this code to get the…
ferpega
  • 3,182
  • 7
  • 45
  • 65
5
votes
2 answers

How to dynamically set log file using App.config and System.Diagnostics?

I was looking for a solution to provide logging to my latest project when I came across an article ( http://www.daveoncsharp.com/2009/09/create-a-logger-using-the-trace-listener-in-csharp/ ) that talked about using System.Diagnostics and App.config…
Simpleton
  • 797
  • 4
  • 11
  • 22
4
votes
4 answers

How to determine if a Process has started but not yet exited?

I have some code that creates a Process instance and later starts it. There's some logic that need to check if the Process has been started. HasExited can be used to check if a started process has been exited, but I can not find a similar function…
larsmoa
  • 12,604
  • 8
  • 62
  • 85
4
votes
4 answers

How do I manage an external Windows application in C#?

What is the best way to manage an external windows application in C# (or .NET)? So far my I've been able to launch a process using System.Diagnostics.Process, however this simply allows me to launch/kill a process. (from what I've gathered) I…
James
  • 2,445
  • 2
  • 25
  • 35
4
votes
2 answers

MemberNotNullWhen (or other code analysis attributes) for inherited members?

I have a class: public abstract class InvestorAccount { public bool IsRegistered => ...; } And a subclass: public class PrivateInvestorAccount : InvestorAccount { public Person? Holder { get; set; } } I would like to teach the compiler…
Dejan
  • 9,150
  • 8
  • 69
  • 117
4
votes
0 answers

Process.Start() in C# does not work for non-admin users

I am trying to run explorer.exe to open a folder and I am using System.Diagnostics.Process to do that. It works fine if the application is ran by a user who has admin privileges but fails if the user is not an admin. I have tried: - running it by…
George
  • 41
  • 1
  • 2
4
votes
2 answers

Get trace file name from TextWriterTraceListener?

I'm using TextWriterTraceListener in my application, if file is not available to write trace, it create another trace file with GUID prefix. All I'm interested is to get the trace file name. In normal condition, I know what would be the filename,…
Prashant Cholachagudda
  • 13,012
  • 23
  • 97
  • 162
4
votes
4 answers

What's the advantage of [insert your favorite logging library here] over System.Diagnostics.Trace?

Apologies if I overlooked it but I couldn't immediately find a similar question on SO. .Net comes with some built-in logging capabilities (essentially, System.Diagnostics.Debug and System.Diagnostics.Trace). Is there a good reason not to use these…
jeroenh
  • 26,362
  • 10
  • 73
  • 104
4
votes
1 answer

Process.Start("Excel.exe") exits immediately

I inherited some code that is now not working. It is supposed to use the Process class to start "Excel.exe". But if I break on the next line I can see the my process instance has the error: 'process.BasePriority' threw an exception of type…
Mwspencer
  • 1,142
  • 3
  • 18
  • 35
4
votes
0 answers

Get line numbers of fields without using a c# parser

I would like to get the line #s of a type's fields. To get the line #'s of the statements in a method it is simple enough: Type type = typeof(MyClass); MethodInfo methodInfo = type.GetMethod("SomeMethod"); int token =…
user420667
  • 6,552
  • 15
  • 51
  • 83
4
votes
1 answer

DebuggerStepThrough Attribute - How to also skip child Methods

I've been using the System.Diagnostics.DebuggerStepThrough attribute to skip code when working in Visual Studio Debugger. However, there are times when I want it to also skip any methods that are called from within the methods I've applied the…
Code Novice
  • 2,043
  • 1
  • 20
  • 44
4
votes
2 answers

How to make FluentFTP to log to log4net log?

I couldn't find any information on how to do it. Basically FluentFTP is using System.Diagnostics to log their messages. FluentFtp expose the following static method: FtpTrace.AddListener(TraceListener listener); However I don't know if there is any…
Radek Strugalski
  • 560
  • 7
  • 22
4
votes
1 answer

log4net became very slow with caller location information after Windows 10 Fall Creators Update (1709)

I known that the documentation of log4net points out that the logging of caller location information can be very slow and shouldn't be used unless the performance of the software is not affected. And until the Windows 10 Fall Creators Update this…
Jezze
  • 307
  • 3
  • 12
4
votes
3 answers

TextWriterTraceListener does not work

Config file:
Captain Comic
  • 15,744
  • 43
  • 110
  • 148