Recently I had to add an audit feature in a command line tool that I developed. The requirement is very simple, we need to audit any command that was issued with the tool. The audit log should contain the Time stamp, the logged in user’s id, the terminal he/she logged in from, the command name and any arguments that were passed to the command.
The log file should rotate if it reaches a certain size. I needed no fancy formatting nor any debug levels, just plain log messages.
As anyone’s first instinct, I thought I would use Log4J and done with it. I have used Log4J before and did have my share of difficulties. But on a second thought, do I really need Log4J? My requirement is very very simple and I would like to keep my implementation as simple as possible. I did a quick google search and did hit all the usual suspects, Log4J, SL4J, Java Logging API etc. But the one that really caught my eye is Simple Log – anti-logging framework. This was exactly what I was looking for, I glanced over the documentation, downloaded the jar file (~ 21 KB!!) and integrated this with my code. All this took less than 30 minutes and I believe that is really a simple way to log!