I am trying out Log4j right now. I want to implement a logging component which will be responsible to log all the important events of the entire web application run.
Can you please suggest me a cool strategy of implementing this so that I can easily generate logs and store them to various file locations and make them Archive too.
I have gone through the API and found nice code that will work great. But I am not able to come up with a GENERIC component for logging. And little confused where to put logging code. Since it�s the first time I am trying LOGGING.
posted 7 years ago
There are two ways I can think of based on your problem:
One is to create your own logging level and appender, then invoke the log(YourLevel, message) in your classes (this would mark the important events in your application).
Then in your appender, filter out those events which match YourLevel and perform your own custom processing.
Or simply re-use the existing levels (INFO sounds like a good candidate) but you'll be in trouble once other classes in your application starts using this level in their logs inappropriately.