개요 로그를 JSON으로 출력하는 방법은 여러가지가 있다. Logback의 LoggingEventCompositeJsonEncoder을 이용해서 출력하는 경우에 대해 설명한다. 이름에서 알겠지만 LoggingEventCompositeJsonEncoder이기 때문에 JSON형식일 때만 가능하다. LoggingEventCompositeJsonEncoder을 이용하는 경우 동적 필드 설정도 가능하다. (다른 encoder에서도 기본 지원인지는 미확인) 구동 환경 pom.xml org.springframework.boot spring-boot-starter-parent 3.2.0-SNAPSHOT org.springframework.boot spring-boot-starter-web org.springframew..
개요 3개의 프로젝트가 있는데 로그의 로그시간 부분의 키와 포맷이 각각 달랐다. 어느쪽이건 키와 포맷을 일치시키고 싶다. 프로젝트 환경 키 포맷(실제값) A Python Powertools timestamp 2023-08-04 02:32:41,872+0000 B Java logback date 2023-07-03T17:28:48.377+09:00 C Java logback eventTime 2023-06-30 07:10:38.923 logback은 전체 포맷을 지정해 놓아서 기존 포맷을 그냥 고치면 되는데, Powertools의 경우에는 디폴트값을 이용하기 때문에 내가 원하는대로 표시하기 위해 조사하였다. timestamp키의 포맷만 바꾸는 경우, timestamp가 아닌 키로 바꾸는 경우, 전체 포맷을..
개요 코드의 실행시간을 체크하기 위한 코드를 작성했었으나 간이 툴로 로그를 처리해야 결과를 알 수 있어서 불편했었다. 별도의 API를 만드는 방법도 있겠으나 별도의 프로젝트를 만들기도 기존 코드에 API를 추가하기도 망설여졌다. 프로젝트 초기부터 AWS X-Ray를 도입하자는 이야기는 있었으나 우선순위에 밀려 대응하지 않다가 이제서야 대응할 수 있었다. X-Ray에 대한 지식도 없고 적용하는 방법도 하나가 아니라서 이것저것 알아보다가 다른 사람의 시행착오를 줄이고자 정리한다. AWS X-Ray에 대하여 기본 사항 공짜는 아니다. 매달 10만건 까지는 무료이고 초과하면 1백만건당 5USD이다.(2023/08/02 기준) https://aws.amazon.com/ko/xray/pricing/ 모든 리퀘스트에..
상황 200개의 리퀘스트를 던지는 부하테스트 중에 max DB connection pool을 200으로 설정하면 아래와 같은 에러가 발생함. ### Error querying database. Cause: org.postgresql.util.PSQLException: ERROR: could not open file "base/16384/16729": Input/output error ### The error may exist in jp/co/toppan/aiocr/bpo/app/domain/repository/EntryRepository.java (best guess) ### The error may involve jp.co.toppan.aiocr.bpo.app.domain.repository.Entry..
아래와 같은 테이블 tbl_entry가 있을 때 id status assign 1 100 F 2 100 F 3 100 F 4 200 F 5 200 F 요청이 들어오면 assign = F인 id 오름차순 첫번째 레코드를 가져와서 assign을 T로 바꾸고 해당 레코드의 정보를 화면에 표시한다. 가져오는 SQL SELECT * FROM tbl_entry WHERE status = ? AND assign = F OFFSET 0 LIMIT 1 그런데 동시에 3명의 유저가 같은 동작을 실행하면 모두가 id=1인 레코드를 가져버린다. 이걸 방지하기 위해서는 "FOR UPDATE"를 쓰면 되는데 이걸 쓰면 해당 레코드에 락이 걸려서 트랜잭션이 끝날 때까지 기다린다. 해당 레코드에 락을 거는 SQL SELECT * F..
문제 여러개로 나뉘어진 로그파일에서 같은 requestId인 것들끼리 파일로 만들고 있음. 작업하던 중 로그파일의 순서가 뒤엉켜서 에러가 발생. 아래와 같은 파일이 있을 때 myapp_application.2023-07-19.0.log myapp_application.2023-07-19.1.log myapp_application.2023-07-19.2.log myapp_application.2023-07-19.3.log myapp_application.2023-07-19.9.log myapp_application.2023-07-19.10.log myapp_application.2023-07-19.11.log 파이썬에서 listdir로 읽어들일 때는 아래의 순서로 읽어들이는 것을 발견함. myapp_app..
발생문제 redis cluster를 docker로 기동하고 있는데, spring boot app을 docker로 기동해야하는 필요가 생김. redis cluster는 localhost로 연결하고 있었는데, spring boot app이 docker가 되면서 redis cluster의 컨테이너명("redis-cluster")으로 변경함. 로그를 보면 redis에 연결에 성공하는 로그도 보이나, 연결 실패도 발생함. 연결 성공 로그 {"level":"DEBUG","message":"Connecting to Redis at redis-cluster:6379: Success","stackTrace":""} 연결 실패 로그 {"level":"ERROR", "message":"Application run faile..
https://leetcode.com/problems/palindrome-number/ Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.정수형 숫자가 회문인지 아닌지 판단하시오. 앞에서부터 읽어도 뒤에서부터 읽어도 같은 경우 회문인 숫자입니다. Example 1:Input: 121Output: trueExample 2: Example 2:Input: -121Output: falseExplanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore ..
https://leetcode.com/problems/reverse-integer/ Given a 32-bit signed integer, reverse digits of an integer. 32비트의 부호있는 정수가 있다, 정수의 숫자를 반전시켜라. Example 1:Input: 123Output: 321 Example 2:Input: -123Output: -321 Example 3:Input: 120Output: 21 Note: Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−231, 231 − 1]. For the purpose of thi..
https://leetcode.com/problems/add-two-numbers/ You are given two non-empty linked lists representing two non-negative integers.The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 itself. Example:Input: (2 -> 4 -> 3) + (5 -> 6 -..
- Total
- Today
- Yesterday
- SnakeYAML
- PostgreSQL #sequnceName
- reverse integer
- 로그파일인덱스
- logback #logstash #LoggingEventCompositeJsonEncoder #로그JSON
- cannotResolveSymbol
- PostgreSQL #FOR UPDATE #SKIP LOCKED
- 로그테스트 #콘솔로그테스트 #System.out
- Maven LF #메이븐 개행문자
- leetcode
- springintegration #파일감시 #디렉토리감시 #파일완료검사
- excel table
- add two numbers
- Postgresql #MultiTruncate
- spring #redis #redis-cluster
- multipleIntegrationFlow
- QR코드읽기 #ReadQRCode
- json
- Python #Powertools
- yaml
- palindrome number
- AWS #X-Ray
- aws #aws region #aws credential #aws region provider #aws credential provier
- excel to markdown
- lombok #maven build #sym
- spring-integration
- Two Sum
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |