Writing to the DSC Operational Log

This topic contains 4 replies, has 2 voices, and was last updated by Profile photo of Mike Fal Mike Fal 2 years ago.

  • Author
    Posts
  • #20512
    Profile photo of Mike Fal
    Mike Fal
    Participant

    Wondering if folks can direct me to the correct way to to do this. Currently I'm working on a custom DSC resource for installing SQL Server and I am trying to write troubleshooting messages to the DSC Windows log (ideally the Operational log, but I figure Analytic or Debug would work the same way). I'm not finding any good web hits on how to do this and it feels like I'm missing something obvious. Can anyone direct me to a "how to" or similar guidance for this?

    Thanks.

  • #20513
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    You can use Write-Verbose and Write-Debug in your DSC resource code, and DSC will take care of the rest. If I remember correctly, Verbose output goes into the Operational log, and Write-Debug goes into the Debug log, but don't quote me on that. 🙂 I don't have a system up where I can quickly double check that at the moment.

    Edit: Looks like I might have been wrong about where Write-Verbose goes. http://blogs.msdn.com/b/powershell/archive/2014/01/03/using-event-logs-to-diagnose-errors-in-desired-state-configuration.aspx mentions that Verbose output goes to the Analytic log, not Operational.

  • #20515
    Profile photo of Mike Fal
    Mike Fal
    Participant

    Odd that, because I'm using Write-Verbose, but the information doesn't seem to be hitting the Operational Log. I can revisit it, make sure I'm doing what I think I'm doing. And, just to make sure I'm on the correct track, will it post an error to those logs if I use Write-Error?

  • #20516
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    Check out the link I just posted in the edit to my last reply. According to that, Verbose output goes to the Analytic log, and Errors go to the Operational log. (Write-Debug, I assume, goes to the Debug log.)

  • #20517
    Profile photo of Mike Fal
    Mike Fal
    Participant

    Thanks Dave, much appreciated. Not super concerned about which log the output goes to, just that it goes somewhere.

You must be logged in to reply to this topic.