When I execute my Java program for the first time the logs are added to a.log. But when I execute the program again, the logs are appended to the existing logs only. This makes the log file very big and difficult to understand. Is it possible to create a new log file everytime code is executed.
Secondly, Can I print the same logs to console as well which are being written to log file.
I would suggest using one of the other appenders, like DailyFileAppender or RollingFileAppender... I'm not looking at the API documentation as I guess these names, so I may have them wrong, but you should look there.
And yes, there's a ConsoleAppender too.
And since this post appears to be about log4j I will move it to the appropriate forum.