----------------------------------------------------------- New Message on MumbaiUserGroup
----------------------------------------------------------- From: UrsRajMVP Message 1 in Discussion Article show you who you can create custom category in event log. We will create custom category (Application, Passport and General) and log event to specific category, for this u require to create the custom message DLLs. Here we created AppMsg.dll AppMsg.dll defines the custom category (Application, Passport and General) for event log this category are defined in AppMsg.rc file i.e. resource file, this resource file is complied into .dll to display custom message in event log. Thus this new component/DLLs needs to be deployed on the application server from where u will write the event log code. <o:p> </o:p> EventLog.WriteEntry(�MY APPLICATION NAME�, �MYEventMessage� ,EventLogEntryType.Warning,101,(short)1); <o:p> </o:p> A default categories of event log are defined as follows: 0 none, 1 Devices, 2 Disk, 3 Printers, 4 Services, 5 Shell, 6 System Event, 7 Network. If you create an event with a category higher than 7, then the category will be shown as a number in parenthesis, for example, (9). You can provide your own category descriptions if you provide a DLL with format strings and refer to this file in the CategoryMessageFile(an element of registry given below) value. There is also a value called CategoryCount(element of registry given below), which gives the number of categories defined in the resource file(.MC).To create the resource file, you use the Win32 tool, mc.exe, which can be found in the Common7\Tools\Bin folder in the Visual Studio .NET folder. (This tool can also be found in the Platform SDK.) Basically the entries for resource file look like this: MessageId=0x1 Language=English MessageId=0x1 Language=English Application<o:p></o:p> . MessageId=0x1 Language=English MessageId=0x1 Language=English Passport<o:p></o:p> . MessageId=0x1 Language=English MessageId=0x1 Language=English General<o:p></o:p> . The first entry is the category ID, the second one is the localization, and after that is the actual string (in this case �Category String�) followed by a period on a single line. Save the above as AppMsg.MC <o:p> </o:p> Use the following step to compiles this to a binary resource (.bin) file ,this should be compiled to a resource file (.res) with the message compiler rc.exe. Finally use the .NET linker (al.exe) and use the /win32res switch. However, this tool mandates that you use /embed, /link, or provide a .NET module on the command line, so you have to provide an AppMsg.NET resource C:> mc AppMsg.mc C:> rc -r -fo AppMsg.res AppMsg.rc C:> echo dummy > dummy.txt C:> al /win32res: AppMsg.res /t:lib /out: AppMsg.dll /embed:dummy.txt ,dummy C:> <st1:place w:st="on"><st1:State w:st="on">del</st1:State></st1:place> dummy.txt Perform the above steps will give you the AppMsg.dll <o:p> </o:p> Finally u need to create a registry entry for the dll follow is registry file code called MyMessage.Reg File Windows Registry Editor Version 5.00 <o:p> </o:p> [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application\MSOpsPortal.Net] "EventMessageFile"="C:\\WINDOWS\\Microsoft.NET\\Framework\\v1.1.4322\\EventLogMessages.dll" "CategoryMessageFile"="%SystemRoot%\\System32\\MsOpsPortalMsg.dll" "CategoryCount"=dword:00000006 <o:p> </o:p> <o:p> </o:p> Below code will display �Application� in the category column in event log EventLog.WriteEntry(�MY APPLICATION NAME�, �MYEventMessage� ,EventLogEntryType.Warning,101,(short)1); Below code will display �Passport� in the category column in event log EventLog.WriteEntry(�MY APPLICATION NAME�, �MYEventMessage� ,EventLogEntryType.Warning,101,(short)2); Below code will display �General� in the category column in event log EventLog.WriteEntry(�MY APPLICATION NAME�, �MYEventMessage� ,EventLogEntryType.Warning,101,(short)3); <o:p> </o:p> <o:p> </o:p> <o:p></o:p> ----------------------------------------------------------- To stop getting this e-mail, or change how often it arrives, go to your E-mail Settings. http://groups.msn.com/MumbaiUserGroup/_emailsettings.msnw Need help? If you've forgotten your password, please go to Passport Member Services. http://groups.msn.com/_passportredir.msnw?ppmprop=help For other questions or feedback, go to our Contact Us page. http://groups.msn.com/contact If you do not want to receive future e-mail from this MSN group, or if you received this message by mistake, please click the "Remove" link below. On the pre-addressed e-mail message that opens, simply click "Send". Your e-mail address will be deleted from this group's mailing list. mailto:[EMAIL PROTECTED]
