Cannot open log for source '.NET Runtime'. You may not have write access

Ajmot Sk 1 Reputation point
2022-01-25T17:34:30.037+00:00

I have created on Blazor server app with default template in VS2022 and added one new API controller class with single get method to return some data from PGSQL. Its throwing error as

An error occurred while writing to logger(s). (Cannot open log for source '.NET Runtime'. You may not have write access.)

Details:

Inner Exception: Cannot open log for source '.NET Runtime'. You may not have write access.

Source: Microsoft.Extensions.Logging

I have tried to provide all access in the log in reg editor in Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\System\CustomSD and Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\CustomSD but still throwing the same error.

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,596 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. AgaveJoe 28,536 Reputation points
    2022-01-25T18:25:02.303+00:00

    The error is telling you that the logger does not have permissions to write to the log. Assuming the error is coming from Web API and Web API is running on IIS, then you must grant right access to the application pool identity Web API is running under.

    Application Pool Identities

    Otherwise, you'll need to tell us a bit more about how the logger works. Normal troubleshooting stuff, like provide a code sample that reproduces this issue.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.