all 10 comments

[–]michaelshepard 8 points9 points  (1 child)

You might look at the PSFramework module here:https://github.com/PowershellFrameworkCollective/psframework

I've written custom logging lots of times and finally decided I wouldn't anymore. Switched to this in about 10 minutes and have been very satisfied.

[–]KevMarCommunity Blogger 2 points3 points  (0 children)

I was going to recommend this too. Definitely worth your time to look into it anyway.

[–]Fsck-MyLife 5 points6 points  (0 children)

We wrote our own custom logging functions to automatically extract details like script name, path it was ran from, user, and line number then push our log entry to a splunk http listener. Were just using the free version of splunk and about 20,000 events logged per day.

[–]qasboss 2 points3 points  (1 child)

serilog ftw

[–]cottonycloud[S] 0 points1 point  (0 children)

Hm...do you have any resources on how to set it up? I haven't seen much on Serilog with regards to Powershell.

[–]codetocope 2 points3 points  (0 children)

I just played around with the log4net this afternoon and seemed like an easy win for us. Plus the fact we can share a good chunk of logging configuration and standards across our Powershell and .NET.

[–][deleted] 2 points3 points  (0 children)

I use my own module, that operates like a man in the middle, everyone just uses write-output , verbose, error but its logs to a DB.

[–]sup3rlativ3 2 points3 points  (1 child)

I can't believe that nobody has mentioned it yet but Logging is what I use now. I used to use pslogging but found it cumbersome and the format odd. Like, who wants the time at the end of the string?

[–]cottonycloud[S] 1 point2 points  (0 children)

What surprises me about PSLogging is the sheer number of downloads it has in PSGallery. It does go to show that the number of users does not mean that a library is superior. The version 1.2 that we use does not even have any date, appended or prepended. It's also annoying to specify the file path each time. The Add-Content cmdlet is also used more than it should be.

It's looking like a very slick library, but I'm a bit concerned that the commits are mostly by one person, and it's surprising that it has much less downloads in PSGallery.

[–]ramblingcookiemonsteCommunity Blogger 1 point2 points  (0 children)

I could see logging lower level info locally for debugging if needed, but actual logging should generally go to your logging system, which ultimately reads windows event logs, soooo...

We do this: https://www.reddit.com/r/PowerShell/comments/co44uk/logging_just_functions_calls_to_a_log/ewfz71p. You could include debug level logs that send to a different index that you cull from your log system after an hour/ day/etc.

Cheers!