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. Trace Question

Trace Question

Scheduled Pinned Locked Moved C#
questiondebugginghelp
2 Posts 2 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.
  • O Offline
    O Offline
    occcy
    wrote on last edited by
    #1

    hi! i've a question about Trace. i want to use the trace (System.Diagnostic nemaspace) mechanism to generate (on demand) error and/or state messages for the eventlog. but it's only possible to generate information messages (Type=Information), no warnings or errors?! or is it possible anyway? :confused: here's my code:TraceListener Listener=new EventLogTraceListener("myApp"); Trace.Listeners.Add(Listener); ... void doSometing() { try { //... do something } catch(Exception e) { //... handle exception and write message to eventlog... Trace.WriteLine(e.Message,"Error"); } }
    thanks in advance!

    X 1 Reply Last reply
    0
    • O occcy

      hi! i've a question about Trace. i want to use the trace (System.Diagnostic nemaspace) mechanism to generate (on demand) error and/or state messages for the eventlog. but it's only possible to generate information messages (Type=Information), no warnings or errors?! or is it possible anyway? :confused: here's my code:TraceListener Listener=new EventLogTraceListener("myApp"); Trace.Listeners.Add(Listener); ... void doSometing() { try { //... do something } catch(Exception e) { //... handle exception and write message to eventlog... Trace.WriteLine(e.Message,"Error"); } }
      thanks in advance!

      X Offline
      X Offline
      XRaheemX
      wrote on last edited by
      #2

      If you're wanting specifically to work with the eventlog, try using the System.Diagnostics.EventLog class. This will provide all of the writing methods you will need -- including writing an "error" event.

      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