by-nc-sa     개발자, DBA가 함께 만들어가는 오라클클럽 지식창고!

Apache rotatelogs




Apache rotatelogs

  • rotatelogs는 아파치 로그파일을 간단하게 관리 할 수 있게 해준다.
  • rotatelogs는 $APACHE_HOME/bin 디렉토리에 존재한다.

1. 간단 문법

1.1 Syntax

rotatelogs  [ -l ] logfile  [ rotationtime [ offset ]] | [ filesizeM ]

1.2 옵션

  • -l : 순환주기로 GMT 대신 지역시간을 사용한다.
  • logfile : 로그파일의 경로와 이름.
  • rotationtime : 로그파일을 순환할 초단위 시간.
  • offset : UTC에서 분단위 시간차이. 생략하면 0. UTC -5 시간대의 지역시간을 사용한다면 -300을 지정한다.
  • filesizeM : 시간이 아닌 크기를 지정할 때 메가바이트단위. 최대 파일크기 뒤에 M을 붙인다.

2. 사용 예제

2.1 시간을 이용한 설정

  • 매일 새벽 00 시에 error 로그 파일명이 error.yymmdd 로 생성된다.
ErrorLog "|/usr/local/apache/bin/rotatelogs -l /usr/local/logs/oracleclub/error.%y%m%d 86400"

2.2 로그파일 사이즈를 이용한 설정

  • access 파일 용량을 1G로 제한 하는 예제
SetEnvIf Request_URI "\.(gif|jpg|png|bmp|swf)" dontlog
SetEnvIf Request_URI "\.(css|js)" dontlog
CustomLog "|/usr/local/apache/bin/rotatelogs -l /usr/local/logs/oracleclub/access.%y%m%d 1024M" common env=!dontlog

3. Reference

문서정보

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.