ProxyMapService Diagnostics in Windows Event Log
ProxyMapService now supports outputting diagnostic messages directly to the Windows Event Log.
1. Enabling Event Log Logging
To enable writing events to the Windows Event Log, you need to make a small change in your project’s configuration file — appsettings.json.
Add the EventLog section within the Logging block, specifying the desired minimum logging level. The example below sets the level to “Information”:
{
"Logging": {
"EventLog": {
"LogLevel": {
"Default": "Information"
}
}
}
}
💡 Note: The
Defaultlevel within theEventLogsection determines the minimum level (Trace, Debug, Information, Warning, Error, Critical) at which messages will be written to the log.
2. Mandatory Step: Registering the Event Source (PowerShell)
Attention! For messages to be successfully displayed in the Event Log and for the system to correctly identify their source and formatting, it is necessary to register the event source with the name ProxyMapService beforehand.
Event source registration is only required once upon installation or update of the service.
Use PowerShell run as administrator and execute the following command. This command creates the necessary registry key:
New-EventLog -LogName Application -Source ProxyMapService
New-EventLog: The cmdlet used to create a new event source.-LogName Application: Specifies that the source will write to the standard “Application” log.-Source ProxyMapService: Sets the source name, which must match the name used within the service code.
3. Viewing the Events
After configuring appsettings.json and registering the source, restart the ProxyMapService. All events at the Information level and above will now be available for viewing in the Windows Event Viewer under Windows Logs $\rightarrow$ Application.
Look for messages with the Source: ProxyMapService.
🔗 Source Code and Discussion: As always, you can find the latest version of the project on GitHub: https://github.com/optinsoft/ProxyMapService