좋아, 이제 두 가지 주제 정리해줄게:
Spring 애플리케이션
↓ (Logback + JSON Encoder)
Logstash (TCP/UDP 수신)
↓
Elasticsearch (검색 저장소)
↓
Kibana (웹 UI 대시보드)
<appender name="logstash" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<destination>127.0.0.1:5000</destination>
<encoder class="net.logstash.logback.encoder.LogstashEncoder" />
</appender>
<root level="INFO">
<appender-ref ref="logstash"/>
</root>
Promtail 또는 Fluent Bit으로 Loki로 전송 가능AsyncAppenderAsyncAppender는 내부 큐를 이용해 비동기 처리 → 애플리케이션 응답 속도 ↑<appender name="asyncConsole" class="ch.qos.logback.classic.AsyncAppender">
<appender-ref ref="console" />
<queueSize>512</queueSize>
<discardingThreshold>0</discardingThreshold>
</appender>
<root level="INFO">
<appender-ref ref="asyncConsole"/>
</root>
logback-spring.xml + Spring profile 연동<springProfile name="dev">
<root level="DEBUG">
<appender-ref ref="console" />
</root>
</springProfile>
<springProfile name="prod">
<root level="WARN">
<appender-ref ref="rollingFile" />
</root>
</springProfile>
spring:
profiles:
active: dev # 또는 prod
WebSecurityConfigurerAdapter (이전 방식, Spring Security 5까지)@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.anyRequest().authenticated()
.and()
.formLogin();
}
}
✅ 특징: 상속 구조 → 오버라이딩 방식. Spring Security 5.7 이후 deprecated
SecurityFilterChain Bean 방식 (현행 방식)@Configuration
@EnableWebSecurity
public class SecurityConfig {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
.authorizeHttpRequests(auth -> auth
.requestMatchers("/admin/**").hasRole("ADMIN")
.anyRequest().permitAll()
)
.formLogin(withDefaults());
return http.build();
}
}
✅ 특징: 함수형 구성 방식이며, Spring Boot 2.7+/Security 5.7+ 이후 권장
필요하면:
JWT 기반 인증 또는 OAuth2 로그인 흐름도 함께 해줄 수 있어!
어떤 주제로 더 확장해볼까? 😊