Tomcat Catalina.out 로그

이 시나리오는 클라이언트에서 생성된 응용프로그램 로그를 PLURA Log Collector 서버로 전송하는 방법을 설명합니다. 이번 예제에서는 Tomcat8의 catalina.out 로그 파일을 사용합니다. PLURA Log Collector 서버를 사용하면 클라이언트(Web Server)에서 별도의 로그 파일을 생성하지 않고, syslog를 통해 직접 전송할 수 있어 CPU, 메모리 등의 리소스 사용량을 최소화할 수 있습니다.


1. 클라이언트: Tomcat8의 catalina.out

  • 환경: CentOS 6 (64비트), Rsyslog 5.8.10

1-1. rsyslog.conf 파일 다운로드

curl -s https://repo.plura.io/v5/module/rsyslog/v5-stable/00-imfile.conf -o /etc/rsyslog.d/00-imfile.conf
curl -s https://repo.plura.io/v5/module/rsyslog/v5-stable/80-tomcat.conf -o /etc/rsyslog.d/80-tomcat.conf

1-2. rsyslog.conf 파일 수정 (원격 rsyslog 서버로 전송)

vi /etc/rsyslog.d/80-tomcat.conf
 #variables required for non-syslog log file forwarding – application log file
 #edit on your location

 $InputFileName /var/log/tomcat8/catalina.out
 $InputFileTag tomcat8:
 $InputFileStateFile stat-catalina.out

 $InputFileSeverity info
 $InputFileFacility local7
 $InputRunFileMonitor

 # Send to remote rsyslog server using UDP
 if $programname == ‘tomcat8’ then @PLURA_Log_Collector_Server:514 #UDP
 :programname, isequal, “tomcat8” ~

1-3. rsyslog 서비스 재시작

service rsyslog restart

1-4. 서버 접속 및 디버깅

nc -zu PLURA_Log_Collector_Server 514
 Connection to PLURA_Log_Collector_Server 514 port [udp/syslog] succeeded!

2. 서버

  • 환경: CentOS 7, Rsyslog 8.2010.0

2-1. PLURA Log Collector 서버 설치

https://docs.plura.io/ko/agents/siem/plc

2-2. 원격 클라이언트에서 syslog 전송 허용

firewall-cmd –add-port 514/udp
firewall-cmd –reload

2-3. 로그 파일 수신 여부 확인

ls -al /var/log/plura/

내부 블로그

https://docs.plura.io/ko/agents/siem/uplc/application-log-plc

외부 참고 사이트

https://www.rsyslog.com/doc/v5-stable/configuration/modules/imfile.html

https://www.rsyslog.com/doc/v8-stable/configuration/modules/imfile.html

http://linuxsysconfig.com/how-to-configure-remote-logging-on-rhel6-centos6/

https://www.teimouri.net/centralized-logs-rsyslog/

Last updated