Log runtime Exceptions in Java using log4j

前端 未结 3 1641
终归单人心
终归单人心 2020-12-03 04:56

I am currently building an application using Tomcat, Spring and JAVA. I am using Log4J as my logging library. I currently am logging everything to a text file

3条回答
  •  半阙折子戏
    2020-12-03 05:32

    You can try redirecting the StdErr to use your logger. This should output the result of anything being written to your std err (which should include unhandled exceptions)

    This blog post gives a good rundown on how to do the redirection into a FileHandler that is apart of your logger:

    • Redirecting System.out and System.err to a rolling log file (Nick Stephen's blog)

提交回复
热议问题