diff --git a/build-container.sh b/build-container.sh new file mode 100644 index 0000000..a63a788 --- /dev/null +++ b/build-container.sh @@ -0,0 +1,2 @@ +#!/bin/sh +docker build ./source/ -t stevedinn/caddy-log-converter:latest diff --git a/source/CaddyLog-To-AccessLog.ps1 b/source/CaddyLog-To-AccessLog.ps1 index b60fdee..a720967 100644 --- a/source/CaddyLog-To-AccessLog.ps1 +++ b/source/CaddyLog-To-AccessLog.ps1 @@ -21,7 +21,9 @@ $outputWriter = New-Object -TypeName System.IO.StreamWriter -ArgumentList @($out Get-Content -Tail $lines -Wait -Path $inFile | ForEach-Object { $l = ConvertFrom-Json -InputObject $_ $r = $l.request; - $ua = $r.headers.'User-Agent' + + $userAgent = $r.headers.'User-Agent' | Select-Object -First 1 + $referer = $r.headers.Referer | Select-Object -First 1 $null = $builder.Clear() $null = $builder.Append($r.remote_ip) @@ -40,9 +42,9 @@ Get-Content -Tail $lines -Wait -Path $inFile | ForEach-Object { $null = $builder.Append(" ") $null = $builder.Append($l.size) $null = $builder.Append(" """) - $null = $builder.Append($r.headers.Referer) + $null = $builder.Append($referer) $null = $builder.Append(""" """) - $null = $builder.Append("$ua") + $null = $builder.Append($userAgent) $null = $builder.Append("""") $commonLog = $builder.ToString()