Logging in Service Management Automation (SMA)

In Service Management Automation (SMA) there are a couple of different ways to write to a log. In this blog post I will show you how to write to the job history tab and how to write to an external SQL database.

If you have published a runbook you can use Write-Verbose, Write-Progress and Write-Debug as shown in figure 1 to write log message. The result of write actions will be shown in History for each runbook job, example shown in figure 2. Figure 3 show important settings to make this work, you need to enable logging on the runbook, else you will see no log messages in the job history.

Figure 1 Write to log examples

Figure 2 Log examples

Figure 3 Log settings

Another alternative for logging is logging to an external database. We have earlier used the same logging solution for Orchestrator runbooks. Figure 4 shows a SMA runbook that writes to a SQL database named SMALOG. As you can see in figure 4 the “writelog” SMA runbook use three parameters, Runbook, Job and Description. Other runbooks invoking this runbook need to provide current runbook, current job ID and a log message description. To get the current runbook name and job ID you can use the code shown in figure 5. The writelog runbook use the Get-Date to get current time. The log database is shown in figure 6.

Figure 4 SMA runbook writes logs to SQL database

Figure 5 Get current runbook name and job ID


Figure 6 Example of log database

Download examples here. Logging┬á. Note that this is provided “AS-IS” with no warranties at all. This is not a production ready solution, just an idea and an example.




2 comments Categories: SMA

2 thoughts on “Logging in Service Management Automation (SMA)

  1. Great article, thanks.

    Especially figure 5 is a good hint, as it is basically the “Common Published Data” for SMA ­čÖé

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.