Hi,@Corner Bowl Software. Welcome Microsoft Q&A.
The Insufficient system resources exist to complete the requested service error typically occurs when there is a limitation or lack of system resources required to perform the requested operation. In this case, it seems that the error is related to the EventLogConfiguration constructor in your code.
You could try the following steps:
Ensure the application runs with elevated privileges: Try running the application as an administrator by right-clicking the application executable (e.g., .exe file) and selecting "Run as administrator."
Check permissions: Ensure that your user account has sufficient permissions to access the event log. If you're running the application in a restricted environment, you may need to contact your system administrator for the necessary permissions.
Verify event log settings: Ensure that the event log you're trying to access ("Microsoft-IIS-Logging/Logs") exists on the system and is accessible.
Check system resource usage: Verify that your system has sufficient resources available (such as memory and disk space) to complete the operation.
Use a try-catch block to handle exceptions: Wrap your code in a try-catch block to catch any exceptions that might occur and handle them appropriately. This will help you identify the specific exception that is being thrown and provide more detailed information about the error.
try
{
using var session = new EventLogSession();
_ = new EventLogConfiguration("Microsoft-IIS-Logging/Logs", session);
}
catch (Exception ex)
{
Console.WriteLine("An error occurred: " + ex.Message);
}