已锁定 reading remotly eventlogs

  • 2012年3月9日 13:17
     
     

    hi;

    plz can any one tell me, how can read the eventlogs remotly

      replay fast

全部回复

  • 2012年3月9日 16:45
     
     

    Hi

    This Article explained how to, 

    http://www.codeproject.com/Articles/3183/Enhanced-EventLog-writing-for-NET-Applications


    If this post answers your question, please click "Mark As Answer". If this post is helpful please click "Mark as Helpful".

  • 2012年3月13日 18:03
     
     

    Sir i m very thankful to u to giving me replay but its not my Answer Plzzz can you give me an easy C# code with Guide Lines Plzzz halp its my project and plzz replay fast THANK,S

  • 2012年3月14日 5:38
     
      包含代码
     

    Hi

    Check with this code,

      
    static void Main(string[] args)
            {
                try
                {
                    //Checks logName is available in remotemachine, but not is remote machine exists
                    //We can specify machineName as either name or IPAddress
                    if (EventLog.Exists("Application", "machineName"))
                    {
                        var log = new EventLog("Application", "machineName");
                        Console.WriteLine(string.Format("{0} Entries found", log.Entries.Count));
                        foreach (EventLogEntry entry in log.Entries)
                        {
                            Console.WriteLine(string.Format("Entry type: {0} - Date: {1} - Source: {2}", entry.EntryType.ToString(), entry.TimeGenerated.ToString(), entry.Source));
                        }
                    }
                }
                catch (IOException)
                {
                    Console.WriteLine("Remote machine provided does not exists");
                }
    
    
                Console.ReadKey();
            } 

    Hope this helps you... 



    If this post answers your question, please click "Mark As Answer". If this post is helpful please click "Mark as Helpful".


    • 已编辑 Kris444 2012年3月14日 5:39
    •  
  • 2012年3月14日 13:34
     
     

    when i m try to perfom remotly read eventlogs then this excption "Attempted to perform an unauthorized operation." arise

    this is the code 

    plzz help me 

    using System;
    using System.Diagnostics;




    class EventLogExporter
    {
        static void Main(string[] args)
        {
            EventLog evtLog = new EventLog("Application");  // Event Log type
            evtLog.MachineName = "192.168.1.2";  // dot is local machine


            foreach (EventLogEntry evtEntry in evtLog.Entries)
            {
                Console.WriteLine(evtEntry.EventID);
                
            }
            Console.WriteLine(evtLog.Entries.Count);
            
           /* EventLogEntry evtEntry = evtLog.Entries;
            Console.WriteLine(evtEntry.Message);*/


            evtLog.Close();
            Console.ReadLine();
        }
    }
  • 2012年3月14日 13:42
     
     

    i tried your code but it give an Excption "Unuthorised opreation "

    is there is any setting on remote pc i have to make ?