c# - Writing to Windows EventLog from arbitrary source -


i'm trying write windows eventlog different sources recreate series of events on system. idea take event's xml , recreate in eventlog. far i've figured out how create simple event arbitrary provider based on source name eventlog.writeentry("service control manager", "a test message", eventlogentrytype.information, 7036, 0); that's classic log, doesn't support more advanced data structure need mimic modern log. i've tried using system.diagnostics.eventing.eventprovider.writeevent, works provider guids (i can work power-troubleshooter not service control manager example). haven't been able find on internet , i've been searching few days, helpful if knew way - in c# or not.

 using system;    using system.collections.generic;    using system.linq;    using system.text;    using system.diagnostics.eventing;  using system.diagnostics;  namespace etwdemo   {       class program       {           static void main(string[] args)           {             //this writes simple message event             eventlog.writeentry("service control manager", "a basic message", eventlogentrytype.information, 7036, 0);              //the rest of writes modern eventlog             //this guid service control manager             var eventprovider = new eventprovider(new guid("{555908d1-a6d7-4695-8e1e-26931d2012f4}"));             if (eventprovider.isenabled())                 console.writeline("provider enabled");                 //outputs 'true' on system             eventdescriptor eventdescriptor;             unchecked             {                 eventdescriptor = new eventdescriptor(                     7036, //eventid                     0, //version                     0x0, //channel id                     0x4, //level                     0x0, //opcode                     0x0, //task                     (long)0x8000000000000000); //keywords             }             var wroteok = eventprovider.writeevent(ref eventdescriptor, "pls", "wrk");             if (wroteok)                 console.writeline("claims have written correctly");             else                 console.writeline("did not write correctly");             //console outputs "claims have written correctly", nothing changes in eventlog         }     }   }  


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -