EventLog el = new EventLog("Application");

el.Source = "my_src_name";

el.WriteEntry("오류 메시지", EventLogEntryType.Error);


다음과 같은 오류 발생

Security Exception

 Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: The source was not found, but some or all event logs could not be searched.  Inaccessible logs: Security.

Source Error:

[No relevant source lines]


Source File: c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\license\3ebadbd0\51884812\App_Web_2wv6qvf1.0.cs    Line: 0

Stack Trace:

[SecurityException: The source was not found, but some or all event logs could not be searched.  Inaccessible logs: Security.]
....


해결방법

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog -> NETWORK SERVICE user에 Full Control 퍼미션 추가

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\my_src_name 키 직접 추가

블로그 이미지

란마12

,