Skip to content

AEM Error Log Parsing with Environment

AEM ERROR log parsing done using Jenkins on a remote host under various environments. In Jenkins, I have used parameterised build plugin and Powershell plugin

Step-01: User Parameters


Step-02: Password Parameter


Step-03: Host parameter


Step-04: Powershell Build Script

<span style="font-size:1rem;"># Stopping the job if it encounters error, ignoring warnings</span>
<div>$ErrorActionPreference = 'Stop'</div>
<div>$warningPreference = 'SilentlyContinue'</div>
<div># Credentials are stored in env and dynamic variables</div>
<div>$SecurePassword = ${ENV:Password} | ConvertTo-SecureString -AsPlainText -Force</div>
<div>$cred = New-Object System.Management.Automation.PSCredential -ArgumentList ${ENV:User}, $SecurePassword</div>
<div># Parameters</div>
<div>[String]$AEMENVNUM = (${ENV:myhost} | %{ $_.Split(',')[3]; })</div>
<div>[String]$AEMENV = (${ENV:myhost} | %{ $_.Split(',')[2]; })</div>
<div>[String]$HOSTENV = (${ENV:myhost} | %{ $_.Split(',')[1]; })</div>
<div>[String]$ServerName = (${ENV:myhost} | %{ $_.Split(',')[0]; })</div>
<div># Logic to parse the error log</div>
<div>[ScriptBlock]$SDScriptBlock = {</div>
<div>write-output "Executing ErrorLogParsing on HOST Environment=${HOSTENV}, AEM Environment=${AEMENV}, AEM Instance Number=${AEMENVNUM}"</div>
<div>$PATH = "C:UsersSKYDEVOPSDesktoptestenv${AEMENV}logserror.log"</div>
<div>$OUTPATH = "C:UsersSKYDEVOPSDesktopbackups"</div>
<div>$TIMESTAMP = $(get-date -f yyyy_MM_dd_hhmmss)</div>
<div>$REGEX = "^.**b(ERROR)b*.*$"</div>
<div>select-string -Path $PATH -Pattern $REGEX -AllMatches | % { $_.Matches } | % { $_.Value } | % { $_.substring($_.indexOf(':')+19) } | Get-Unique | Group-object | Format-Table -Wrap -AutoSize -Property Count,Group &gt; ${OUTPATH}errorLogFilter-$AEMENV-$TIMESTAMP.log</div>
<div># Invoke a command on the remote machine.</div>
<div>Invoke-Command -ComputerName $ServerName -Credential $cred -ScriptBlock ${SDScriptBlock} -ArgumentList $AEMENV,$ServerName,$HOSTENV,$AEMENVNUM</div>

Step-05: Console Output


Step-06: Parsed Log Output



Adobe Experience Manager, Adobe Experience Manager 6.x, AEM, aem63, Linux, Powershell, Windows Server, Windows Service


, ,

Shashi View All

A passionate devops and automation engineer

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: