Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. System.Net.Sockets - Tracing with TraceSource class

System.Net.Sockets - Tracing with TraceSource class

Scheduled Pinned Locked Moved C#
debuggingquestioncsharp
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    wurzel_cidermaker
    wrote on last edited by
    #1

    If you create a <[yourAppName].exe.config> file like the one below, you will see extra "socket" debug tracing information. However when I try to do this programmatically (below), I don't see any trace info. <<< TraceSource ts = new TraceSource("System.Net.Sockets", SourceLevels.Verbose); ConsoleTraceListener consoleListener = new ConsoleTraceListener(); consoleListener.Name = "console"; ts.Listeners.Add(consoleListener); >>> The question is why? Can it be done programmatically? Here's the config file that works...

    W 1 Reply Last reply
    0
    • W wurzel_cidermaker

      If you create a <[yourAppName].exe.config> file like the one below, you will see extra "socket" debug tracing information. However when I try to do this programmatically (below), I don't see any trace info. <<< TraceSource ts = new TraceSource("System.Net.Sockets", SourceLevels.Verbose); ConsoleTraceListener consoleListener = new ConsoleTraceListener(); consoleListener.Name = "console"; ts.Listeners.Add(consoleListener); >>> The question is why? Can it be done programmatically? Here's the config file that works...

      W Offline
      W Offline
      wurzel_cidermaker
      wrote on last edited by
      #2

      I received this from Microsoft. To configure you the listeners and level of logging for a listener you need a reference to the listener that is going to be doing the tracing. Your call to create a new TraceSource object creates a trace source with the same name as the one used by the System.Net.Sockets classes, but it's not the same trace source object, so any changes do not have an effect on the actual TraceSource object that System.Net.Sockets is using. Because of this, you'll need to use the application configuration file to enable the trace. The tracing config settings lets you listen to messages from a trace source (in this case from Socket classes) but the TraceSource instance itself remains private and inaccessible directly/programmatically. Think of it this way – you don’t want to grant direct access to your trace source instance and let someone send messages under disguise but you do want to allow operations to configure what level of information you trace and where you trace etc…

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups