Using store_artifacts to capture debug/error logs

How do I capture error logs when a build fails and archive them so we can see additional details on why a build or test run failed without having to re-run the build or ssh into the build container.

I have tried to use this for the moment:

      - store_test_results:
          path: /tmp

Although there should be a better way to do this, I don’t think the above will work if the break does not complete with success. How best to setup the .circleci/config.yml in such cases.

What happens to all the logs files created by Java, for eg. hs_err.log or any other Hotspot log files once the build stops or breaks due to an error.

Some good examples of best practices would certainly help.