I have 2 questions regarding log4j :
1. How do I disable appending to the log files when running an application again ? (Now the logging is just being appended to the last run logging generating a very big log file)
2. How can I disable logging to the console ? (Now every log I make is written to the proper file(s) but also to the console)
Thanks in advance.
What are your real logging purposes?
Are you using log for info, debug or warns and errors?
Is this logging for development or you have finished
and you move your code to productional server?
Is your logging file growing to fast?
Who will read log file is something goes wrong? Developer? Client?
Answer all those questions, and that will be input info for
your log4j configuration in each development phase of your project.
There are many appenders that can be used:
ConsoleAppender, FileAppender, SMTPAppender, RollingFileAppender...
How to you configure log4j? If you are using log4j.properties there will be:
That is a place to add or remove your appenders.
Also that is place where you set up your log level : trace, debug....fatal.
If you have log file size problems you can use RollingFileAppender with
DailyRollingFileAppender which creates on file per day, but configuring this
in multithread app can be real pain.
Take your time and study your logger configuration.