1. Create a log for the source
The source is created, and the log is displayed in Event Viewer/applications and services logs/custom source, which has a relatively high level of treatment and is specially displayed.
The Administrator is required to create the source. Otherwise, crash is required.
If you have already enabled computer management, close it and then open it to see the source you just created.
CodeAs follows:
//Create the source, if it does not already exist.If(!EventLog. sourceexists (logsource) {EventLog. createeventsource (logsource, LOGNAME);} EventLog. writeentry (tbsourcename. text, tbmessage. text, type, getvalue (tbeventid. text), getcategory value (tbcategory. text ));
After the source is created, you do not need the Administrator identity to write logs.
In actual use, create the source when installing the software.
2. If you do not create a source, the code will be
EventLog. writeentry (tbsourcename. Text, tbmessage. Text, type, getvalue (tbeventid. Text), getcategvalue (tbcategory. Text ));
The administrator ID is required for each operation.
Logs are displayed in event viewers/Windows logs/application.
3. Each log contains two types of information: general and details, which are detailed but seem useless.
In short, it is not very nice.
Writing is also messy. Sorry!
Demo