The Source Was Not Found, But Some or All Event Logs Could Not Be Searched

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

See creating a registry key.

This problem can occur not only due to permissions, but also due to event source key missing because it wasn't registered successfully (you need admin privileges to do it - if you just open Visual Studio as usual and run the program normally it won't be enough). Make sure that your event source "MyApp" is actually registered, i.e. that it appears in the registry under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\eventlog\Application.

From MSDN EventLog.CreateEventSource():

To create an event source in Windows Vista and later or Windows Server
2003, you must have administrative privileges.

So you must either run the event source registration code as an admin (also, check if the source already exists before - see the above MSDN example) or you can manually add the key to the registry:

  1. create a regkey HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\eventlog\Application\MyApp;
  2. inside, create a string value EventMessageFile and set its value to e.g. C:\Windows\Microsoft.NET\Framework\v2.0.50727\EventLogMessages.dll

The source was not found, but some or all event logs could not be searched

EventLog.SourceExists enumerates through the subkeys of HKLM\SYSTEM\CurrentControlSet\services\eventlog to see if it contains a subkey with the specified name. If the user account under which the code is running does not have read access to a subkey that it attempts to access (in your case, the Security subkey) before finding the target source, you will see an exception like the one you have described.

The usual approach for handling such issues is to register event log sources at installation time (under an administrator account), then assume that they exist at runtime, allowing any resulting exception to be treated as unexpected if a target event log source does not actually exist at runtime.

Asp.Net MVC - SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security

When the system starts it tries to initialize the logger component. In the default installation this is a simple event logger that tries to write events into the Windows Event Log - and if the appropriate log does not exist, it tries to create it on-the-fly. In some environments the application user does not have (Windows) permissions for this, which is normal.

You have multiple options:

  • create the event log manually (see the createeventlog SnAdmin tool here)
  • use a different logger that writes log entries somewhere else, not the Event log. For example there is the SnFileSystemEventLogger that writes entries to the file system. To configure the logger you may use the repository builder API in your MvcApplication:

```

public class MvcApplication : SenseNet.Portal.SenseNetGlobal
{
protected override void Application_Start(object sender, EventArgs e, HttpApplication application)
{
...
}

protected override void BuildRepository(IRepositoryBuilder repositoryBuilder)
{
repositoryBuilder.UseLogger(new SnFileSystemEventLogger());
}
}

The source was not found, but some or all event logs could not be searched using SignalR

For testing you can set an admin user as Identity of your application pool.
By default the value is ApplicationPoolIdentity.

Sample Image

If it works you should add permission for the Network Service and add it as user of your app pool. You should add permission to this user on this registry key :
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Security

Windows 2008 - The source was not found, but some or all event logs could not be searched

Your application is probably trying to write to an event source that doesn't exist. You can create an event source as follows: How to create Windows EventLog source from command line?.

Determine which event source your application is trying to write to and create it.

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

If you are being prompted for a user name and password, then something, somewhere is set to Account = ServiceAccount.User - that's the only way that could (should) happen. Perhaps your code in the comment above is not being executed or it is being changed back by later executing code.

As far as your second paragraph, in general, I would think a service would be fine for this if you don't want it to be see on the console or run as a task. I am not sure if I understand the part about running it as ASP.NET and having it not allow you to see the database...

Finally, in your last paragraph, I can't speak to the NullExeception without knowing more about what is going on in your installer's code.



Related Topics



Leave a reply



Submit