본문 바로가기

Vue/bookStore

2. bookStore (기본 세팅)

1. Logging - logback


성능상 문제와 System.out.println()로 로그가 쌓이면 원하는 부분을 찾지 못한다. 따라서 logging툴을 사용하여 log를 쓸 것이다.

 

Logging 설정 (slf4j - logback)  
slf4j : @slf4j 어노테이션 하나만 쓰면 로그변수를 쓸 수 있다
logback : 은 구현체 역할을 한다

 

1. pom.xml 라이브러리 추가

 

        <!-- lombok, slf4j -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>

 

2. src/main/resources에 logback-spring.xml파일 추가

 

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <include resource="org/springframework/boot/logging/logback/defaults.xml" />

    <springProfile name="local">
        <include resource="org/springframework/boot/logging/logback/console-appender.xml"/>

        <logger name="com.bookstore" level="DEBUG"/>
        <root level="INFO">
            <appender-ref ref="CONSOLE"/>
        </root>
    </springProfile>

    <springProfile name="prod">
        <appender name="FILE-ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
            <file>app.log</file>

            <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
                <fileNamePattern>logs/archived/app.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
                <!-- each archived file, size max 10MB -->
                <maxFileSize>10MB</maxFileSize>
                <!-- total size of all archive files, if total size > 20GB, it will delete old archived file -->
                <totalSizeCap>20GB</totalSizeCap>
                <!-- 60 days to keep -->
                <maxHistory>60</maxHistory>
            </rollingPolicy>

            <encoder>
                <pattern>%d %p %c{1.} [%t] %m%n</pattern>
            </encoder>
        </appender>

        <logger name="org.springframework" level="INFO"/>
        <logger name="com.bookstore" level="WARN"/>
        <root level="ERROR">
            <appender-ref ref="FILE-ROLLING"/>
        </root>
    </springProfile>

</configuration>

 

로그의 5단계 
   1. trace (일반적으로 남기는 이벤트 기록)
   2. debug (디버깅용)
   3. info (알림)
   4. warn(경고)
   5. errror
  로그 단계를 올리면 해당 로그부터 보여준다

 

 

 

2. git-ignore


 

.gitignore 파일을 최상위 디렉토리에 만들고 아래의 문법에 따라 작성하자

 

# : comments

# no .a files
*.a

# but do track lib.a, even though you're ignoring .a files above
!lib.a

# only ignore the TODO file in the current directory, not subdir/TODO
/TODO

# ignore all files in the build/ directory
build/

# ignore doc/notes.txt, but not doc/server/arch.txt
doc/*.txt

# ignore all .pdf files in the doc/ directory
doc/**/*.pdf

 

그리고 .gitignore 파일을 같이 push해주면 적용된다.

 

'Vue > bookStore' 카테고리의 다른 글

4. bookStore - Book CRUD  (0) 2022.02.06
3. BookStore jwtToken 인증 추가  (0) 2022.02.06
book Entity - Setter ? Builder?  (0) 2022.02.02
1. bookStore (DB 테이블 생성)  (0) 2022.01.31
Springboot 와 Vue.js 를 사용하여 bookStore만들기  (0) 2022.01.31