- Use Logentries to create a manual
Token TCP
log set. - Change $token to match your new log
- Put the function at the top of your PS script
- Call $le.Log() any time you need output.
- Use the log entries
Live Tail
feature. It's not always immediate, give it up to a couple of minutes for your entries to appear. - Until there is some logging in your log set, it may take even longer to see your first log entry. Prime the log if you can, by outputting something to it immediately. Run the script with the included
Hello!
to start this process.
Last active
September 29, 2015 14:29
-
-
Save squeedee/632eec98e695ce682f8a to your computer and use it in GitHub Desktop.
Logging to Logentries from powershell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$le = New-Module -AsCustomObject -ScriptBlock { | |
$port = 80 | |
$remoteHost = "data.logentries.com" | |
$socket = new-object System.Net.Sockets.TcpClient($remoteHost, $port) | |
$stream = $socket.GetStream() | |
$writer = new-object System.IO.StreamWriter($stream) | |
$token = "Loge-entries-tag-here" | |
Function Log { | |
param ( $Message ) | |
$writer.WriteLine($token + " : " + $Message ) | |
$writer.Flush() | |
} | |
Export-ModuleMember -Function Log} | |
$le.Log("Hello!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment