I have to make some improvements to a Powershell script.
So I have a script that is getting started multiple times with different parameters.
These scripts now all write to the same logfile using log4net. I know, not great, but I don’t have time to change the logging completely and I “inherited” the responsibility for this script.
Now like I expected, I get errors like these:
log4net:ERROR [RollingFileAppender] Unable to acquire lock on file
log4net:ERROR [RollingFileAppender] OpenFile
My question is now:
Can I create a try/catch around my log commands where I catch a “RollingFileAppender” exception?
I tried googling but I didn’t find a type for that. I can’t test either because this script is highly specialized and won’t take an input, that is only for testing purposes ( I know, great lol). I will try to recreate parts of the script for testing but that will take some time and so I figured I’d ask here first.
If “RollingFileAppender” isn’t the exception type, does someone know what type of exception it is?