Questions tagged [tracesource]

61 questions
34
votes
2 answers

Difference between using Trace and TraceSource

Anyone knows the difference between System.Diagnostic.Trace and System.Diagnostic.TraceSource classes? I've been using Trace for most of my projects and I just happen to found out about TraceSource the other day. They seems to offer similar API, is…
oscarkuo
  • 10,431
  • 6
  • 49
  • 62
24
votes
4 answers

Format of Tracing output in System.Diagnostics.TraceSource

The following code: static void Main(string[] args) { TraceSource ts = new TraceSource("MyApplication"); ts.Switch = new SourceSwitch("MySwitch"); ts.Switch.Level = SourceLevels.All; ts.Listeners.Add(new…
Flagg1980
  • 295
  • 1
  • 2
  • 7
6
votes
2 answers

How are TraceSource names resolved in a .NET program?

The MSDN documentation for the TraceSource class has an example of how the app.config file can list out information for TraceSource instances: http://msdn.microsoft.com/en-us/library/system.diagnostics.tracesource.aspx However, there is no…
Matt
  • 61
  • 3
5
votes
3 answers

How do you stop a TextWriterTraceListener from appending using app.config?

I'm using System.Diagnostics.TraceSource for logging and one of my listeners is a TextWriterTraceListener. In the tracing primer here it sets this up as follows:
Matthew Finlay
  • 3,354
  • 2
  • 27
  • 32
5
votes
1 answer

Can I use TraceSource in ASP .Net Core for logging?

TraceSource is accessible from System.Diagnostics in my ASP .NET Core project. In src file you can find header: #region Assembly System.Diagnostics.TraceSource, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a // C:\Program…
5
votes
1 answer

When do I need more than one TraceSource in code?

If one application is writing all its activity data in one log file, is there any use of having more than one TraceSource? I am just curious about the uses cases where one will need more than one TraceSource in the code.
imak
  • 6,489
  • 7
  • 50
  • 73
5
votes
1 answer

OWIN interferes with log4net

In my application, I've got the following logging strategy/appenders: DebugAppender: If the root level is DEBUG, write every message that matches DEBUG to the default trace listener output ConsoleAppender: If the application mode (global context…
xvdiff
  • 2,179
  • 2
  • 24
  • 47
4
votes
1 answer

Common.Logging for TraceSource

I am trying to adopt Common.Logging in our application, however I am having some trouble setting it up with system.diagnostics. It works with straight up Trace, but not TraceSource. I was using Common.Logging.Simple.TraceLoggerFactoryAdapter. Do i…
Eatdoku
  • 6,569
  • 13
  • 63
  • 98
4
votes
1 answer

TraceSource locking file

I have an instance of a class that lives for a very long time (hours to months). It has a method that outputs log events to a text file C:\mylog.txt. As below public MyClass { private static System.Diagnostics.TraceSource traceSource = new…
Kevin Brydon
  • 12,524
  • 8
  • 46
  • 76
4
votes
1 answer

Loading configuration for System.Diagnostics.TraceSource from an xml file

In log4net, it is possible to choose between loading the configuration from the app.config, or from an arbitrary xml file. Is it possible to load the configuration for System.Diagnostics.TraceSource from an arbitrary xml file?
Kornél Regius
  • 2,989
  • 5
  • 30
  • 39
3
votes
2 answers

TraceSource and ASP.NET: Works for Web Applications, not WebSites

I'm adding tracing functionality to an ASP.NET website so I decided to investigate TraceSource by creating a couple of prototypes; a Web Application project and a Website project. I'm using similar Web.config for each project to log traces to the…
Bullines
  • 5,626
  • 6
  • 53
  • 93
3
votes
1 answer

Write to same log file two instances of the same application

How write to same file from two instance of the same application. For write I used TraceSource class with TraceEvent method from System.Diagnostis namespace. I try create method with Mutex for write, but my method don't work correctly. I can't find…
user3305198
  • 73
  • 1
  • 2
  • 7
3
votes
4 answers

Should a TraceSource be guarded with "if" statements?

Before tracing to a TraceSource, should the "Trace Level" be checked prior to issuing the trace itself? var ts = new TraceSource("foo"); ts.Switch.Level = SourceLevels.Warning; if (/* should there be a guard here? and if so, what? */) { …
user2864740
  • 60,010
  • 15
  • 145
  • 220
3
votes
1 answer

How can I tell -all- .NET Trace Sources to user a listener?

I have various class libraries that have trace sources in them. Works fine. In my .config file, I need to specific which source will dump it's text to the listener. Fine, works great. But i have about 20 sources with all the same switch value and…
Pure.Krome
  • 84,693
  • 113
  • 396
  • 647
3
votes
5 answers

TraceSource : Custom TraceListener not working

I'm using TraceSource to log the ASP.Net application. To change the output format I need to create own TraceListener instead of TextwriterListener.
C-va
  • 2,910
  • 4
  • 27
  • 42
1
2 3 4 5