First you need to change the code in the first post to have a method in the class the contains the code you have there.
Then depending on how you configure the Logger class (note Capital letter in...