Creating User Log
Events
The
EventManager.LogUserEvent
method
allows you to create user log
Event
objects. You can associate
your custom
Event
with any managed entity.
User log events are useful for marking actions or status associated with the
objects your application deals with.
The following steps show how to create a user
log Event.
- Obtain the managed object reference to theEventManager... ManagedObjectReference _svcRef = new ManagedObjectReference(); ServiceContent _sic = my_conn.retrieveServiceContent(_svcRef); ManagedObjectReference eMgrRef = _sic.getEventManager(); ...
- Obtain the managed object reference to the entity with which you are associating theEvent.For example, suppose you have a reference to a virtual machine (myVMRef) and you want to log a message to record the fact that a virus check completed. You want to usemyVMRefas a parameter to theLogUserEventmethod in the next step.
- Call theLogUserEventmethod, passing in theEventManagerand theEventreference and a string consisting of the Event message for themsgparameter of the operation.LogUserEvent(eMgrRef, myVMRef, "Completed virus check at 1:05 AM on Sunday December 21.");
User-defined Event objects display in the
vSphere Client among the other events on the system, with the prefix User
logged event: followed by the text submitted in your
msg
parameter. In other client
applications, such as in the console-based Event sample applications, custom
events display as
com.vmware.vim.GeneralUserEvent
objects.