2023-01-05-TIL

Today I Learned

Java Logging Best Practices

  • https://sematext.com/blog/java-logging-best-practices/
  • https://www.atatus.com/blog/best-practices-in-java-logging/

Audit Log

  • https://www.servicenow.com/kr/products/governance-risk-and-compliance/what-is-an-audit-log.html
  • https://helpx.adobe.com/kr/enterprise/using/audit-logs.html
  • https://www.datadoghq.com/knowledge-center/audit-logging/
  • http://blog.plura.io/?page_id=7353
  • https://www.iso27000.es/assets/files/ISO27k%20Guideline%20on%20ISMS%20audit%20v2.pdf

Spring AOP

  • https://docs.spring.io/spring-framework/docs/2.0.x/reference/aop.html
  • https://helpx.adobe.com/kr/enterprise/using/audit-logs.html

How to get HttpServletRequest in Spring AOP

The easy way to do it is to rely on RequestContextHolder. In every request, the DispatcherServlet binds the current HttpServletRequest to a static ThreadLocal object in the RequestContextHolder. You can retrieve it when executing within the same Thread with

HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();
  • https://stackoverflow.com/questions/19271807/how-to-inject-httpservletrequest-into-a-spring-aop-request-custom-scenario

java.lang.IllegalStateException: getReader() has already been called for this request

이미 InputStream에서 한 번 읽어들인 데이터인데, AOP에서 getReader로 다시 읽으려고 해서 예외가 발생한다. 해결 방법으로는 한 번 읽어들인 데이터를 별도로 저장해두었다가 꺼내어서 사용하던가,

  • https://stackoverflow.com/questions/7318632/java-lang-illegalstateexception-getreader-has-already-been-called-for-this-re
  • https://dylee.tistory.com/6
  • https://meetup.nhncloud.com/posts/44

How to logging request body in AOP

  • https://taetaetae.github.io/2019/06/30/controller-common-logging/

HttpServletRequest

  • https://blog.naver.com/islove8587/220349614028