I need to make a script that will find the "Error" in the log file and after this error copy its description, which is in a separate string. I manage to find and copy the entire error string, but it turns out that the block with the error description is located a little lower and I can not copy it.
Select-String C:\TEMP\Skript\Log.xml -Pattern ' level="ERROR" ' -AllMatches | select | out-file C:\TEMP\Skript\LogErrors.xml -append
How do I specify additional parameters for a search?
The comment is in a separate block and not on the same line with the error. This block is not necessarily 1 line long.
<log4j:event logger="COMP" timestamp="1579174503853" level="ERROR" thread="1"><log4j:message>
here comes
a long error discription
for a few lines.
</log4j:message>
This is where the error description ends. So i must find ERROR in log and then copy this string and the description.
Expected Result: Get an every error with its description, even if the error description takes several lines.
<log4j:event logger="COMP" timestamp="1579174503853" level="ERROR" thread="1"><log4j:message>
here comes a long error discription for a few lines.
</log4j:message>
-Context 0,1withSelect-Stringto grab one line after the match