Skip to content

Monitoring & Troubleshooting

David Wiseman edited this page Jan 30, 2025 · 2 revisions

Monitoring

It's important to monitor your log shipping. The standard transaction log shipping status report isn't available with custom log shipping implementations. DBA Dash has log shipping monitoring that will work with custom log shipping implementations like this. You can query the msdb history tables instead to check the health of your log shipping. e.g.

SELECT	D.name AS DB,
		D.state,
		D.state_desc,
		D.is_in_standby,
		t.backup_finish_date,
		t.restore_date,
		DATEDIFF(mi,t.restore_date,GETDATE()) as MinsSinceLastRestore,
		DATEDIFF(mi,t.backup_finish_date,GETDATE()) AS TotalTimeBehindMins,
		t.physical_device_name AS LastLog,
		t.is_force_offline AS IsTailLog,
		CASE WHEN t.is_force_offline=1 THEN 'RESTORE DATABASE ' + QUOTENAME(t.destination_database_name) + ' WITH RECOVERY' ELSE NULL END AS [Restore Command (Printed if tail log is restored)]
FROM sys.databases D
OUTER APPLY(SELECT TOP(1)	rsh.destination_database_name,
							bs.backup_finish_date,
							rsh.restore_date,
							bmf.physical_device_name,
							bs.is_force_offline
		FROM msdb.dbo.restorehistory rsh
		INNER JOIN msdb.dbo.backupset bs ON rsh.backup_set_id = bs.backup_set_id
		INNER JOIN msdb.dbo.restorefile rf ON rsh.restore_history_id = rf.restore_history_id
		INNER JOIN msdb.dbo.backupmediafamily bmf ON bmf.media_set_id = bs.media_set_id
		WHERE rsh.restore_type = 'L'
		AND D.name =  rsh.destination_database_name
		ORDER BY rsh.restore_history_id DESC
	) t
WHERE (D.state = 1 OR D.is_in_standby=1)
ORDER BY t.backup_finish_date;

Troubleshooting Checklist

  • Check Logs folder.
    The application writes detailed logs so you can see exactly what the service is doing. If you don't have any logs it's possible that the service account doesn't have permissions to write to the application folder. Check the permissions on the folder. You can also try running the application directly where it will output it's logs to the console.
  • LogShippingService.exe can also be run from the console for troubleshooting purposes.
  • Check permissions
  • Check the config file is valid json. Ensure all \ in paths are replaced with \\. It's also easy to miss commas etc.
  • Blob container paths are case sensitive. Ensure the correct case is used.

Logging

Serilog is used for logging. In most cases, you shouldn't need to modify this section of the config file.

 "Serilog": {
    "Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
    "MinimumLevel": "Debug",
    "WriteTo": [
      {
        "Name": "Console",
        "Args": {
          "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj} <{ThreadId}>{NewLine}{Exception}"
        }
      },
      {
        "Name": "File",
        "Args": {
          "path": "Logs/log-.txt",
          "rollingInterval": "Hour",
          "retainedFileCountLimit": 24,
          "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj} <{ThreadId}>{NewLine}{Exception}"
        }
      }
    ],
    "Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
    "Properties": {
      "Application": "LogShippingService"
    }
}
Clone this wiki locally