I am trying to modify an already written Windows service.
I see the source has an System.diagnostic.EventLog object which logs different action of the service.
I am trying to figure out how do i read this log. From semantics it seems that Eventlog is logging several actions of service.
where is this log stored, how can i see it, i need access to it as my service sometimes stop intermittently.
I tried to google it but did not find any solid answers. Putting the questions simply what is an eventlong and how do i use it.
In 'Computer Management' you'll see an entry labelled 'Event Viewer'. Depending on which version of Windows you're running, there will be several sub-entries below this conforming to each of the event logs Windows maintains. Your application will probably be logging to the 'Application' log, although it might also log to 'System'. Click these subitems to have their log contents show up in the central pane.
Related
I have a Windows Desktop application written in C# that takes information from Windows services, web services, databases and other components running on various remote Windows servers for specific stages in a process. Currently, the application reads information from a shared database to get an indication of when to move on to the next step in a process, but the details and verbose information that each component outputs to its logs is not captured in the shared database, and I want to capture this log information in a "master process steps detail" type list that the Windows Desktop application can display to users.
Is there a best method or practice for capturing logs in various formats from multiple Windows servers?
There are similar questions on Stack Overflow, but they seem to be based more in the Linux or other non-Windows servers:
Best way to aggregate multiple log files from several servers
I was told that perhaps WMI might be able to help somehow, but would like confirmation.
Thanks for your reply.
Several sources outside of StackOverflow have recommended that I look into using Elastic Stack, so I'm moving forward with that for now.
Net Masters,
We design an ASP.NET MVC web application, this application integrated with thierd party to exchange some information, the process of preparing the required information take around 3 minutes, I want to handle this by allow end user to click s button then to show status of transfer info "waiting for send" during this a record in DB will be created, database table will consedered as a queue for set of tasks, Now we need a tool to keep verify if there is a task in the queue to perform, if it found a record then it will perform set of operation to prepare info to be sent to external entity, we have an idea to create custom wcf service to handle this senario, but before start this development effort I need to ask if there is any tool that could achive this rather than develop it from scratch since we have set of case to handle (for example if third party not accessable then the service need to keep attempt to deliver the required info).
Maybe hangfire.io is "your tool".
As David wrote: there no special "tool". Only a lots of ways to handle your dev task with projects like quartz.net, hangfire, rabbitMQ, ...
I have a strange issue where I need to see why my application pool is crashing due to a permissions issue and no logs are helpful. Is there any way to log every file access attempt on a system and sort it by the user/system account that tried to access it, especially if it fails in accessing the desired file? Even if there are third party applications for this, it would be very helpful.
Process Monitor by Sysinternals/Microsoft will show that and a lot of other activities.
When I run a piece of code that I wrote I keep getting the following error:
The source was not found, but some or
all event logs could not be searched.
Inaccessible logs: Security.
I have double checked and I am not manually writing to the logs anywhere, so I assume my application is doing it on it's own.
I found this post, which suggest that I give read/write permissions to a registry entry that corresponds to the Event Logs. I had three questions about this:
Is this the correct way to fix this
error?
If I go this route, should I give permissions to whatever my app pool is running under? (it's a web app)
Is it secure to give read/write access to that registry key?
This definitely seems like a permissions issue. It has to do with the fact that the Source you are trying to write into the event log does not already exist. Once it is created, this error should go away. Since you just need to make sure the Source gets added that first time, you could try the registry approach (grant access to the AppPool user), and then remove the registry access after the source has been created.
I've worked around this issue by manually adding the Source to the Event Log using a dialog app I wrote that I run as Administrator. Once the Source is added, all of the other event logging works fine. If you know the Source that it's trying to use when it writes to the event log, you could try that approach as well.
I have two Windows services written in C# following the same patterns and methodology.
Both services were development tested against a Windows 7 VM and QA tested on Windows Server 2008 VM. Both services have been installed and uninstalled many times under these test environments without issue, however upon installing in the production environment (Windows Server 2008) one of the two services refuses to start.
To install the services we are using InstallUtil.exe with ServiceInstaller and ServiceProcessInstaller components attached to the service.
By all appearances, the failing service installs successfully. InstallUtil.exe reports success and the service appears in the Services snapin. You can also locate the service in the registry under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Blah Blah. However, if you attempt to start the service you get the following:
net start blah.blah.exe
"The service name is invalid."
...or going through the Services snapin...
"Windows could not start the "Blah Blah" service on Local Computer. Error 1053: The service did not respond to the start or control request in a timely fashion."
I have added some event logging to the constructor of the service class failing service, but it does not appear to get called.
As this is a production box, there is no Visual Studio on the box and remote debugging is out of the question.
Is there any other way for me to gain debugging info on why the failing service isn't starting?
Is there any other obvious-ish reason that I might see this kind of issue?
Edit: I should have also mentioned.. The only other evidence of a problem in the Windows Event Viewer is two messages in the System log from the Service Control Manager:
"A timeout was reached (30000 milliseconds) while waiting for the Blah Blah service to connect.
"The Blah Blah service failed to start due to the following error:
The service did not respond to the start or control request in a timely fashion."
Edit: Resolved
The issue ended up being a combination of a configuration mistake and a bug that was hiding it. See my answer below for more details.
Jeopardy Answer: "How might invalid custom configuration combined with a bad global exception handler manifest itself in a .NET Windows service?"
Figured it out.
The root cause of the problem was an invalid custom configuration section in the app.config. We use a custom configuration section to configure the service from the app.config and the assembly and namespace of the ConfigurationSection derived class had changed recently.
As it turns out, our production configuration was looking for the definition of the custom ConfigurationSection in the wrong assembly and the exception thrown when failing to instantiate it was getting hidden by a bug where exceptions caught early in the life of the service would attempt to be logged to the custom log rather than the Application event log. (Since the event log source did not exist on the custom event log, this would throw another exception from the global exception handler and the service would die in the constructor.)
This second exception did not get logged anywhere and we only found it through code inspection.
The resolution was to fix the configuration and to modify the global exception handler to only attempt to write to the Application event log using the service name as the event log source. (InstallUtil registers the service name as an event log source on the Application log.)
Thanks for the help everyone! Sorry this particular issue ended up being so specific to our setup.
It could be possible from the error message that you've described
net start blah.blah.exe "The service name is invalid."
That the name that you gave the service in the service install component that you added in visual studio is not what you think it is.
I've had this problem quite a few times with developers misnaming services in installs.
what are you trying to do on service start?
also check the account through which the service is running and the account has the necessary privileges.
I've run into problems like this many times while programming my own services, so I'll just list out a bunch of things that at various points solved my problems and hope that they help you:
I've had to restart services.msc because I've uninstalled a service it still thought it had a reference to. However, when I would start it, the "service was invalid"
If you're making the service from a console application (so that it can be debugged) but forget to change it back to a service, it won't start.
When I was using InstallUtil.exe, sometimes it would attempt to install multiple copies, so I switched to just using a Setup Project.
Hope that helps in some way.
This is a common issue. What code do you have in your Start event?
You should only have code that activates a Timer when the service starts. This allows the Start event to complete quickly and notify the controller. If the execution takes longer than that, you will get the error you received. There might be some reason (possibly data-related) why its taking longer in production.
When the Timer ticks, execute your code and stop the Timer. Obviously, also put everything in try/catch and log the exceptions.
It is possible for this error to occur when
your service is depending on another service/application
or due to invalid app.config configurations
Encountered the same issue when Entity Framework was unable to connect to the database server due to lack of permission.
Better to add a global level error logging mechanism to your application to debug the issue easily.Event Viewer might not reveal exact details in some scenarios.