Plex creates and abundance of log files. Most large library operators might not even know when and where Plex finds a problem with a media file.
I’ve thrown this PowerShell script together which outputs just the error messages to a new file, since I got tired of reviewing more than one file
YMMV
##########################################
### #Sassan’s Plex Media Analysis Log Parser
##########################################
Clear-Host
### #Plex Log folder - yours will most likely be on another drive
$RootPath = “Z:\\Plex\\Plex Media Server\\Logs”
write-host “Looking for logs in” $RootPath -Foregroundcolor green
### #File to write the collected Error messages to and
### #Define the file path and delete an old output file if it exists
$OutputFile = “C:\\temp\\PlexMediaProblems.txt”
try {
# Check if the file exists
if (Test-Path -Path $OutputFile -PathType Leaf) {
# Delete the file
Remove-Item -Path $OutputFile -Force
Write-Host “Old” $OutputFile “successfully deleted”
}
else {
Write-Host “File does not exist: $OutputFile” -ForegroundColor DarkCyan
}
}
catch {
Write-Host “Error deleting file: $($\_.Exception.Message)” -ForegroundColor Red
}
### #Logfiles to exclude
$ExcludedPatterns = @(“*uploader*”,“*update*”,“*server*”,“*system*”,“*Thumbnails*”,“*transcoder*”,“*agents*”,“*credits*”,“*matcher*”,“*tuner*”)
### #Filtered log files to look at
$Logs= Get-ChildItem -Path $RootPath -Recurse -File -Filter \*.log |
Where-Object {
$fileName = $*.Name
-not ($ExcludedPatterns | Where-Object { $fileName -like $* })
}
write-host “Found” $logs -Foregroundcolor DarkGreen
### #Counting log files to be looked at
$LogCount = $Logs | Measure | Select -ExpandProperty Count
Write-Host "Looking at " $LogCount “Log files for Media Errors” -ForegroundColor Yellow
### #Parsing the filtered Media log files for “Error”
foreach ($log in $Logs) {
Select-String -Path $log.FullName -Pattern “error” -CaseSensitive:$false |
ForEach-Object {
“$($log.FullName):$($*.LineNumber): $($*.Line)” |
Out-File -FilePath $OutputFile -Append -Encoding utf8
}
}
Write-Host “Find Media Errors in” $OutputFile -BackgroundColor DarkYellow