If you are adding a new logging mechanism such as Log4perl to your program, I would highly recommend experimenting in a small program that only does logging. 95% of the code you've posted here has nothing to do with your issue. (See SSCCE.)
One thing that stands out is that you are instantiating your logger each time through the loop. You want it instantiated once and available in the loop. I also don't see any attempt to log an array -- or anything for that matter other than the test statements at error and warn.
Finally, you might consider whether a big logging framework is the right tool for your task or whether simply opening and appending to a file would be enough.
The way forward always starts with a minimal test.