Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 6th, 2012  |  syntax: None  |  size: 0.59 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. using System;
  2. using System.Diagnostics;
  3. using NLog;
  4.  
  5. namespace EventLogSample
  6. {
  7.     class Program
  8.     {
  9.         static readonly Logger Log = LogManager.GetCurrentClassLogger();
  10.        
  11.         static void Main(string[] args)
  12.         {
  13.             if (EventLog.SourceExists("TestNLog", ".") == false)
  14.                 EventLog.CreateEventSource(new EventSourceCreationData("TestNLog", "Application"));
  15.  
  16.             Console.WriteLine("Press enter to finish");
  17.             Log.Debug("Testing debug");
  18.  
  19.             EventLog.WriteEntry("TestNLog", "blah");
  20.  
  21.             Console.ReadLine();
  22.         }
  23.     }
  24. }