Skip to content

Enable logging in Azure Log Analytics

Roger Zander edited this page Jun 29, 2019 · 3 revisions

DevCDR can write Logs to Azure Log Analytics. This is an optional feature and you have to do the following steps to enable it:

Requirements

  • Azure Log Analytics Workspace (Free is able to hold Log-Entries for 7 days)

Activate Log-Analytics on DevCDR instance

In the Azure App Service for DevCDR, select Configuration and add two new Application Settings:

  • Log-WorkspaceID : [your WorkspaceID from Log Analytics]
  • Log-SharedKey : [your SharedKey from Log Analytics]

you have to restart the app service to start logging to Log-Analytic.

Note: it may take a moment until you see the log entries

Activate Log-Analytics on Clients

Installation

Install the "WriteAnalyticsLog" PowerShell Module from the PowerShell gallery on every client:

Install-Module -Name WriteAnalyticsLog -Force

Configuration

To store your connection information on the client use "Set-LogAnalytics" Cmdlet to enter your WorkspaceId and SharedKey:

Set-LogAnalytics -WorkspaceID <string> -SharedKey <string> -LogType <string>

Note: You have to run the Set-LogAnalytics command with your details on every client

Verify

Each Client will encrypt the connection information and store it in registry:

[HKEY_LOCAL_MACHINE\SOFTWARE\itnetx\WriteAnalyticsLogs]
"ConnectionString"="<encrypted data>"

Write a Log-Entry

If you want to store a custom Log-Entry you can use the command:

Write-Log -JSON <Object> [-LogType <string>]

Example:

Write-Log -JSON ([pscustomobject]@{Computer = $env:COMPUTERNAME; EventID = 9999}) -LogType "DevCDRCore"

Note: it may take a moment until you can query the data in Azure Log Analytics