{"id":11334,"date":"2022-09-12T05:56:50","date_gmt":"2022-09-12T12:56:50","guid":{"rendered":"https:\/\/www.coretechnologies.com\/blog\/?p=11334"},"modified":"2022-09-13T22:19:10","modified_gmt":"2022-09-14T05:19:10","slug":"windows-event-logs-problem","status":"publish","type":"post","link":"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/windows-event-logs-problem\/","title":{"rendered":"Q&#038;A: Why isn&#8217;t AlwaysUp Writing to the Windows Event Logs?"},"content":{"rendered":"<div align=\"center\"><img loading=\"lazy\" decoding=\"async\" class=\"no-lazy-load\" src=\"\/blog\/images\/qa-no-event-logs.webp\" style=\"margin-bottom:20px;\" title=\"Why isn't AlwaysUp Writing to the Event Logs?\" alt=\"Why isn't AlwaysUp Writing to the Event Logs?\" border=\"0\" width=\"380\" height=\"160\" \/><\/div>\n<div class=\"blog-qa-question-box\">\n<img loading=\"lazy\" decoding=\"async\" class=\"no-lazy-load\" src=\"https:\/\/cdn.coretechnologies.com\/images\/quotes-transparent-21x21.webp\" width=\"21\" height=\"21\" \/>&nbsp;&nbsp;Hello,<\/p>\n<p>I&#8217;m hoping you can help me troubleshoot some issues we are experiencing with AlwaysUp. We are currently using version 12.9.0.46.<\/p>\n<p>A user reported that something wasn&#8217;t working correctly with the application we&#8217;re running as a service. Upon investigating the issue, I noticed that AlwaysUp doesn\u2019t appear to be writing any logs to the event viewer as stated on <a href=\"https:\/\/www.coretechnologies.com\/products\/AlwaysUp\/AlwaysUp_EventLog.html\" rel=\"noopener\">this page<\/a>.<\/p>\n<p>I thought I was maybe just missing any messages, so I stopped and restarted the service after about 1 minute. However, this also didn&#8217;t write anything to the Application Logs in Event Viewer.<\/p>\n<p>Could you assist me in sorting out the reporting please?<\/p>\n<p align=\"right\">&mdash; Lewis<\/p>\n<\/div>\n<p>Hi Lewis. Let&#8217;s dig into your situation.<\/p>\n<h2 class=\"blog-caption\">Which account runs your application as a Windows Service?<\/h2>\n<p>Do you have a user specified on the <b>Logon<\/b> tab in AlwaysUp? That&#8217;s the account where your application will run.<\/p>\n<p>For example, this screenshot shows OneDrive configured to run as a service in the &#8220;Mike Jones&#8221; account:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/onedrive-alwaysup-logon-tab.png\" class=\"zoomPopup\" title=\"OneDrive AlwaysUp Logon tab\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/onedrive-alwaysup-logon-tab.png\" title=\"OneDrive AlwaysUp Logon tab (click to enlarge)\" alt=\"OneDrive AlwaysUp Logon tab\" border=\"0\" \/><\/a><\/div>\n<p>When we start OneDrive in AlwaysUp, the executable runs as &#8220;Mike Jones&#8221;:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/onedrive-running-task-manager.png\" class=\"zoomPopup\" title=\"OneDrive in Task Manager\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/onedrive-running-task-manager.png\" title=\"OneDrive in Task Manager (click to enlarge)\" alt=\"OneDrive in Task Manager\" border=\"0\" width=\"520\" \/><\/a><\/div>\n<p>And as <a href=\"\/blog\/windows-services\/essential-tools-for-windows-services-process-explorer\/\">Process Explorer<\/a> shows, even AlwaysUpService.exe &mdash; the headless application that runs your application as a service in the background &mdash; operates as the same user:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/alwaysupservice-properties-process-explorer.png\" class=\"zoomPopup\" title=\"AlwaysUpService.exe in Process Explorer\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/alwaysupservice-properties-process-explorer.png\" title=\"AlwaysUpService.exe in Process Explorer (click to enlarge)\" alt=\"AlwaysUpService.exe in Process Explorer\" border=\"0\" \/><\/a><\/div>\n<p>Note that most Windows Services run in the <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/services\/localsystem-account\" target=\"_blank\" rel=\"noopener\">LocalSystem account<\/a> &mdash; a predefined local account used by the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Service_Control_Manager\" target=\"_blank\" rel=\"noopener\">Service Control Manager<\/a>. Indeed, AlwaysUp will run your application as LocalSystem unless you override it by providing an alternate account.<\/p>\n<p>But running in a &#8220;regular&#8221; user account is often the best choice when installing an application as a service. That&#8217;s because <b>most desktop applications are tied to the account where they were installed<\/b>. Starting them in an account where they were not installed (and cannot find settings saved during installation and configuration) usually ends in failure.<\/p>\n<h2 class=\"blog-caption\">That account must have permission to create event logs<\/h2>\n<p>As illustrated above, the service that AlwaysUp creates runs entirely in the context of the account specified on the Logon tab.<\/p>\n<p>In your set up, the account doesn&#8217;t appear to have the necessary permissions to write to the event logs. That&#8217;s why you&#8217;re not seeing any records from AlwaysUp.<\/p>\n<h2 class=\"blog-caption\">Test the account&#8217;s event log permissions with PowerShell<\/h2>\n<p>You can test this theory by running the following PowerShell command <b>from the user&#8217;s account<\/b>:<\/p>\n<div class=\"code-box\">\nWrite-EventLog -LogName Application -Source &quot;<b>APPNAME<\/b> (managed by AlwaysUpService)&quot; -EntryType Information -EventID 0 -Message &quot;This event was created while testing with PowerShell. Please ignore.&quot;\n<\/div>\n<p>Please replace APPNAME with the name of your application in AlwaysUp.<\/p>\n<p>Essentially, the <a href=\"https:\/\/docs.microsoft.com\/en-us\/powershell\/module\/microsoft.powershell.management\/write-eventlog\" target=\"_blank\" rel=\"noopener\">Write-EventLog<\/a> command simulates how AlwaysUp works. If Write-EventLog fails, then AlwaysUp will fail too.<\/p>\n<p>Here is the result of running the command from the &#8220;Mike Jones&#8221; account for our OneDrive service. Write-EventLog succeeded:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/run-write-eventlog.png\" class=\"zoomPopup\" title=\"Test permissions with Write-EventLog\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/run-write-eventlog.png\" title=\"Test permissions with Write-EventLog (click to enlarge)\" alt=\"Test permissions with Write-EventLog\" border=\"0\" width=\"520\" \/><\/a><\/div>\n<p>And a new event showed up in the Application log:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/new-event-viewer-record.png\" class=\"zoomPopup\" title=\"The new record in the Event Viewer\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/new-event-viewer-record.png\" title=\"The new record in the Event Viewer (click to enlarge)\" alt=\"The new record in the Event Viewer\" border=\"0\" width=\"520\" \/><\/a><\/div>\n<p>So everything looked good for Mike.<\/p>\n<h2 class=\"blog-caption\">How to enable event logging from your AlwaysUp service<\/h2>\n<p>You can fix the permission problem in one of three ways:<\/p>\n<ol style=\"margin-bottom:24px\">\n<li>\n<p><b>Grant the user administrative rights.<\/b> As an admin, they will definitely be able to write to the event logs. This may be your easiest way forward.<\/p>\n<\/li>\n<li>\n<p>Leave the user as a non-admin but <b>grant the account specific rights to the Application event log<\/b>. Depending on where the issue is, you may have to update the registry and perform other administrative surgery. These links offer guidance:<\/p>\n<ul>\n<li><a href=\"https:\/\/stackoverflow.com\/questions\/760093\/setting-permissions-on-application-event-log\" target=\"_blank\" rel=\"noopener\">Setting permissions on application event log<\/a><\/li>\n<li><a href=\"https:\/\/docs.microsoft.com\/en-us\/troubleshoot\/developer\/webapps\/aspnet\/development\/fail-write-event-log\" target=\"_blank\" rel=\"noopener\">Fail to write to the Windows event log from an ASP.NET or ASP application<\/a><\/li>\n<\/ul>\n<\/li>\n<li>\n<p><b>Enter a different user with administrative rights on the AlwaysUp Logon tab.<\/b> That account shouldn&#8217;t have any problems creating records in any event logs.<\/p>\n<\/li>\n<\/ol>\n<p style=\"margin-top: 30px\">\nHope this helps!<\/p>\n<!-- relpost-thumb-wrapper --><div class=\"relpost-thumb-wrapper\"><!-- filter-class --><div class=\"relpost-thumb-container\"><style>.relpost-block-single-image, .relpost-post-image { margin-bottom: 10px; }<\/style><h3>You may also like...<\/h3><div style=\"clear: both\"><\/div><div style=\"clear: both\"><\/div><!-- relpost-block-container --><div class=\"relpost-block-container relpost-block-column-layout\" style=\"--relposth-columns: 3;--relposth-columns_t: 2; --relposth-columns_m: 2\"><a href=\"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/virtualbox-vm-powered-off\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"Why does my VirtualBox VM say \u201cPowered Off\u201d when it\u2019s running as a Service?\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/virtualbox-logo-150x150.png\" style=\"aspect-ratio:1\/1\" style=\"aspect-ratio:1\/1\"><\/img><div class=\"relpost-block-single-text\"  style=\"height: 75px;font-family: Arial;  font-size: 12px;  color: #333333;\"><h2 class=\"relpost_card_title\">Why does my VirtualBox VM say &quot;Powered Off&quot; when it&#039;s running as a Service with AlwaysUp?<\/h2><\/div><\/div><\/a><a href=\"https:\/\/www.coretechnologies.com\/blog\/windows-services\/access-session-0-with-vnc\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"How to Use VNC to Remotely Access Session 0 (with Keyboard and Mouse!)\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/vnc-logo-150x150.png\" style=\"aspect-ratio:1\/1\" style=\"aspect-ratio:1\/1\"><\/img><div class=\"relpost-block-single-text\"  style=\"height: 75px;font-family: Arial;  font-size: 12px;  color: #333333;\"><h2 class=\"relpost_card_title\">How to Use VNC to Remotely Access Session 0 (with Keyboard and Mouse!)<\/h2><\/div><\/div><\/a><a href=\"https:\/\/www.coretechnologies.com\/blog\/windows-services\/auto-restart-service\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"Q&amp;A: How do I Automatically Restart my Windows Service when it Crashes?\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/restart-windows-service-150x150-1.png\" style=\"aspect-ratio:1\/1\" style=\"aspect-ratio:1\/1\"><\/img><div class=\"relpost-block-single-text\"  style=\"height: 75px;font-family: Arial;  font-size: 12px;  color: #333333;\"><h2 class=\"relpost_card_title\">Q&amp;A: How do I Automatically Restart my Windows Service when it Crashes?<\/h2><\/div><\/div><\/a><\/div><!-- close relpost-block-container --><div style=\"clear: both\"><\/div><\/div><!-- close filter class --><\/div><!-- close relpost-thumb-wrapper -->","protected":false},"excerpt":{"rendered":"<p>&nbsp;&nbsp;Hello, I&#8217;m hoping you can help me troubleshoot some issues we are experiencing with AlwaysUp. We are currently using version 12.9.0.46. A user reported that something wasn&#8217;t working correctly with the application we&#8217;re running as a service. Upon investigating the &hellip; <a href=\"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/windows-event-logs-problem\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":11339,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[26,290,79,288,127],"class_list":["post-11334","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-alwaysup","tag-alwaysup-tag","tag-event-logs","tag-event-viewer","tag-localsystem-account","tag-qa"],"_links":{"self":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/11334","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/comments?post=11334"}],"version-history":[{"count":11,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/11334\/revisions"}],"predecessor-version":[{"id":11516,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/11334\/revisions\/11516"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/media\/11339"}],"wp:attachment":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/media?parent=11334"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/categories?post=11334"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/tags?post=11334"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}