foreach log message

Good morning, I would like to capture this log message in a variable:
a.png
I set the script like this, but the message doesn’t appear when I do the :put and I don’t have an output.
where am I wrong?

{
:local logMessage ""
:local logIp ""
:local cont1 0
:local cont2 0
/log

:foreach i in=[find where message~"login failed: password is not chap encrypted" or where message~"login failed: RADIUS server is not responding"] do={
    :set logMessage [get $i message]
     }
    :if ($logMessage~"login failed: password is not chap encrypted") do={
        :set $cont1 ($cont1 + 1)
        }
    :if ($logMessage~"login failed: RADIUS server is not responding") do={
        :set $cont2 ($cont2 + 1)
        }
:put $logMessage

}

The script is full of error.
Eg.
where .. or where
} closed too early
set **$**cont