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
9
votes
5 answers

Problem with System.Diagnosis.TextWriterTraceListener not writing any log to the filesystem

To solve an issue with sending e-mail through a smtp-server where e-mails are not getting sent, I was adviced to enable logging using System.Diagnosis.TextWriterTraceListener to trace the communication with the smtp-server to track any errors. I…
Tomas Vinter
  • 2,690
  • 8
  • 36
  • 45
9
votes
4 answers

How to check if process is still running before calling Process.GetProcessById?

In .NET Process.GetProcessById throws an exception if the process with this ID is not running. How to safely call this method so that it won't throw an exception? I am thinking something like if(Process.IsRunning(id)) return…
Louis Rhys
  • 34,517
  • 56
  • 153
  • 221
8
votes
2 answers

System.Diagnostics.ActivitySource.StartActivity returns null

I haven't find the way to make activitySource.StartActivity return non-null activity, which is different comparing to DiagnosticSource.StartActivity behavior. Is it expected? Am I'missing something obvious? I can see docs says: "The created activity…
MaGu
  • 1,125
  • 2
  • 11
  • 14
8
votes
1 answer

How to get a list of all Windows Event Logs (Event Viewer Logs) with their hierarchy and friendly names in C#

I'm trying to replicate the following from the Event Viewer: I'm having trouble with a few things. Some of the names I get back are not the display names or friendly names. For example, for "Microsoft Office Alerts" I just get back "OAlerts". How…
Mark
  • 5,223
  • 11
  • 51
  • 81
8
votes
3 answers

How to determine whether a System.Diagnostics.Process is 32 or 64 bit?

I tried: process.MainModule.FileName.Contains("x86") But it threw an exception for a x64 process: Win32Exception: Only a part of the ReadProcessMemory ou WriteProcessMemory request finished
Jader Dias
  • 88,211
  • 155
  • 421
  • 625
8
votes
2 answers

Performance impact of DefaultTraceListener

When using System.Diagnostics tracing, is there a significant (measurable) performance impact on not removing the "Default" trace listener on a production ASP.NET application in release mode, with the TRACE constant defined at compilation time but…
Fernando Correia
  • 21,803
  • 13
  • 83
  • 116
7
votes
4 answers

Assume always-trust is yes/true in GPG cmd

Im using GPG to encrypt a file in ASP.NET, C#. My code executes the command using ProcessStartInfo, and gpg.exe executes, but I have an issue. GPG asks me to authorize always-trust with "y" as the option. I tried using "YES" as well (As suggested in…
iLevi
  • 936
  • 4
  • 10
  • 26
7
votes
2 answers

Printing newline using System.Diagnostics.Debugger.Log

I am printing a lot of lines in my log while debugging like this: System.Diagnostics.Debugger.Log(0, null, responseFromServer); System.Diagnostics.Debugger.Log(0, null, t[0]); .... All of them are getting printed at the same line.. How can i make…
CuriousCoder
  • 1,582
  • 5
  • 28
  • 55
7
votes
2 answers

C# VS2010 Determine in application whether being debugged

Is there a chance to determine in an C# application whether it is currently being debugged? The idea is to ignore e.g timeouts, or to provide additional information. Just to make this clear, I am not talking about the conditional compiler flag…
Horst Walter
  • 13,663
  • 32
  • 126
  • 228
7
votes
2 answers

Log4net traceappender not logging anything

I'd like to redirect everything logged by log4net to the System.Diagnostics Trace classes. My understanding of what I should be doing is pointing log4net at system.diagnostics.traceappender, then I configure system.diagnostics. Here's important…
JDH
  • 2,618
  • 5
  • 38
  • 48
7
votes
3 answers

Does System.Diagnostics.Trace have any performance degredation?

I am looking for a simple native .NET error logging solution. I am not interested in using log4net, Elmah or any other logging library. Below is what I am planning on using. My question is performance on my site is paramount and does this flow…
Cyberdrew
  • 1,832
  • 1
  • 19
  • 39
7
votes
2 answers

Add a default TraceListener for all TraceSources in App.config

How can I define a default TraceListener, that is automatically added to all TraceSources, in a net 4.0 c# project? Currently I have to list every named TraceSource I use in the App.config file like this:
HugoRune
  • 13,157
  • 7
  • 69
  • 144
7
votes
1 answer

System.Diagnostics.Trace, simplest possible programmatic configuration

The following program does not print the text "This is a trace". There is no app.config. My question is, how can I modify the following code (and only the code, not any configuration files) such that messages passed in calls to t.TraceEvent appear…
628426
  • 373
  • 3
  • 14
7
votes
1 answer

Is it possible to subclass an EventSource in ETW?

I'd like to be able to declare an EventSource which has a minimum of several methods which by default provide regular logging facilities. e.g. Info() Warn() Error() In addition I'd like to be able to within each service, define a specific event…
jaffa
  • 26,770
  • 50
  • 178
  • 289
7
votes
1 answer

Calling System.Diagnostics.Trace from a Dynamics CRM 2011 Plugin

Wondering if any of you have any ideas about the following issue I’m running into. Here is some super simple plug-in code. namespace Demo.DebugTraceBlog { public class TraceAndDebugDemo : IPlugin { public void…
Nicknow
  • 7,154
  • 3
  • 22
  • 38