My application has a rather non-trivial, yet standard, log configuration.
It includes a console appender and a rolling size-based file appender.

When I'm running the tests, thru the IDE or with maven, where is the least surprising place to save the log files?

  • 1
    I like the criterion "least surprising". Though it often seems that the opposite criterion was used. – superM Nov 19 '13 at 12:04
  • 6
    What about a Logs folder in the output folder of your project, or is that too obvious? – CodeCaster Nov 19 '13 at 12:50
  • Is the output of the log part of the test? – user40980 Nov 19 '13 at 15:16
  • @MichaelT Not testing the logs, but would like to look at them if necessary. – Asaf Nov 19 '13 at 15:25
  • @CodeCaster so, if using maven conventions, target\logs would be the right place. I wonder what happens in a multi-module project (will try) – Asaf Nov 19 '13 at 15:28

If I'm checking out a logs on a server at my company I always go straight to the logs folder. In my work place the logs folder is the most intuitive location for logs.

My suggestion is follow how your workplace does it, and if you are starting a new project then create a logs folder.

| improve this answer | |

Automated test when run should not really make a dent on the environment they run in. It is very annoying when you run the test suite on someone else's code and find a bunch of files have been created in random places. This can lead to accidentally adding the files into version control and non-repeatable tests.

With the example of logging I would dump everything out to the console because :

  • You can redirect the logs to a file when running Maven test when required, so mvn test > my_log
  • When running the tests through an IDE you can easily scroll through the output without worrying that your missing something.

If your logging a large amount of data then grep and sed are your friends.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.