-
Notifications
You must be signed in to change notification settings - Fork 584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add function to create custom event log under Microsoft Event Viewer #43
base: master
Are you sure you want to change the base?
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
@googlebot I signed it! |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
This PR (HEAD: 236ae2b) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/sys/+/198493 to see it. Tip: You can toggle comments from me using the |
Message from Gobot Gobot: Patch Set 1: Congratulations on opening your first change. Thank you for your contribution! Next steps: Most changes in the Go project go through a few rounds of revision. This can be During May-July and Nov-Jan the Go project is in a code freeze, during which Please don’t reply on this GitHub thread. Visit golang.org/cl/198493. |
Message from Alex Brainman: Patch Set 1: (2 comments) Thank you for your contribution. I am unclear about what you are trying to build here. So I did not do thorough review. I will do that once we agree on the plan. Alex Please don’t reply on this GitHub thread. Visit golang.org/cl/198493. |
Message from Reed Law: Patch Set 1: (1 comment)
The impetus behind this is that the behavior of the current implementation is to log all messages under the "Windows Logs -> Application" event source. Many applications log events to custom sources under "Applications and Services Logs". The process for manually creating a custom event log source is quite cumbersome unless you leverage .NET (see https://docs.microsoft.com/en-us/windows/win32/eventlog/message-files and https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.eventlog.createeventsource?view=netframework-4.8). A workaround that many have utilized (e.g. https://www.jasonsamuel.com/2010/01/08/creating-a-custom-event-log-under-event-viewer-to-log-server-events/) is to use the existing message file provided by .NET. Please don’t reply on this GitHub thread. Visit golang.org/cl/198493. |
Message from Reed Law: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/198493. |
Message from Alex Brainman: Patch Set 1: (1 comment) Sorry but I am not convinced that this change is correct and useful enough to be included in this package. I suspect that different people will require different keys / values created. I think it is easy enough to do this in their own code. If you disagree, you could easily publish functions to create and remove custom event log in your own package, and make them public. Alex Please don’t reply on this GitHub thread. Visit golang.org/cl/198493. |
Message from Reed Law: Patch Set 1:
Maybe I should file a bug because when I run the example (from golang.org/x/sys/windows/svc/example) I get this error:
If I ignore that error and try logging a message (with
It looks like undesired behavior to me. I understand the hesitancy to reference seemingly random files. Perhaps I didn't describe the issue well to begin with. The Windows Dev Center links I shared were meant to outline in rough form the steps required to get an event source set up. If you are using .NET it's much simpler using CreateEventSource. That method sets up the registry keys in the same way as I have done here. Please don’t reply on this GitHub thread. Visit golang.org/cl/198493. |
Message from Alex Brainman: Patch Set 1:
I agree. This is not a very error good message. But you could easily debug this yourself. Just some print statements in golang.org/x/sys/windows/svc/eventlog.Install function to see what fails and why. And you are always welcome to file bugs at https://golang.org/issue . I don't promise to fix them, but there are many other contributors who are willing to help.
I am not sure exactly what you have done. Maybe show us your exact code. But you will see event log message like this when service registry is not setup properly.
If you are referring to as prove that you implementation is correct, then I don't see it. Where are all keys and values you are creating in this document? I cannot just accept your word that your code is correct. Alex Please don’t reply on this GitHub thread. Visit golang.org/cl/198493. |
Message from Reed Law: Patch Set 1: I appreciate your taking time to review and, most of all, providing this code to begin with. Without it I could not have gotten to where I am now, and I was merely trying to prevent others from experiencing the same frustrations I had with the Windows API. Given I'm not interested in proving my implementation correct and you're not willing to merge it, I thought I'd leave it as a gist for the sake of others who may find it useful: https://gist.github.com/reedlaw/61bb51a1c10326b9fb82162d09388b5c One last thought is that we may be dealing with different Windows versions and thus are not seeing the same results. I'm testing on Windows Server 2012 R2. Thanks again, and feel free to close this merge request. Please don’t reply on this GitHub thread. Visit golang.org/cl/198493. |
Message from Alex Brainman: Patch Set 1:
If you really want your code to be useful to others, you should create Go package instead. So Gophers can download it with simple "go get" command. And also provide nice documentation comments. Just create github.com/reedlaw/customeventlog package with these too functions // InstallCustomLog creates a custom event log under Microsoft Event Viewer. // RemoveCustomLog deletes all registry elements installed by the correspondent InstallCustomLog. You already have the code. It just a matter of creating new Github repo and copying your code there.
I don't see this a problem. I use both Windows 10 and Windows 7. And Go builders test code on many different Windows versions, including Windows Server 2012. If you go to https://build.golang.org , you can see it for yourself. Please don’t reply on this GitHub thread. Visit golang.org/cl/198493. |
Message from Go Bot: Patch Set 1: Congratulations on opening your first change. Thank you for your contribution! Next steps: Most changes in the Go project go through a few rounds of revision. This can be During May-July and Nov-Jan the Go project is in a code freeze, during which Please don’t reply on this GitHub thread. Visit golang.org/cl/198493. |
This function allows creation of an event log with a custom name (i.e. not "Application").