생활 속 지혜, SW/HW Tip 등 유용한 지식 정보를 공유하는 장소 입니다.
본 게시판의 열람 및 다운로드는 비회원도 가능하나 글쓰기 및 댓글은 로그인 사용자만 가능합니다.
서버환경
OS : Winodws XP
Apache version : 2.X
Apache2의 log를 분할 관리하는 방법에 대하여 조사해본 결과 rotatelogs.exe와 cronolog.exe가 많이 사용되고 있었습니다.
하지만 제가 설치해본 결과 아래 그림처럼 CMD 창이 계속 활성화 되는 버그가 생기더군요...
따라서 여러 방면으로 검색하던 결과 module mod_log_rotate를 사용하여 로그 파일을 관리하는 방법이 있었습니다.
1. 첨부 파일 중 해당되는 파일을 다운로드
Module : mod_log_rotate222_08_2006.so
DLL : mod_log_rotate222_08_2006.dll
Apache 2.2 이하 버젼 : http://www.sitebuddy.com/mod_log_rotate
2. Httpd.conf 수정
#To load this module, modify your httpd.conf: (module을 사용하는 경우)
LoadModule log_rotate_module modules/mod_log_rotate.so
#or if using the DLL version (dll을 사용하는 경우)
LoadModule log_rotate_module modules/mod_log_rotate.dll
3. httpd.conf 혹은 httpd-vhosts.conf(가상호스트 사용시) 수정
RotateLogs On
RotateLogsLocalTime On
RotateInterval 86400
ErrorLog /apache2/logs/sever--error.log
CustomLog logs/sever-access_%m_%d_%Y_%H_%i.log combined
4. 아파치 재 실행
주1) error-log는 작동하지 않으며 오직 access log에만 작동한다는 단점이 있습니다.
주2)
RotateLogs On|Off
Enable / disable automatic log rotation. Note: On Apache 2, once enabled mod_log_rotate takes responsibility for all log output server wide even if RotateLogs Off is subsequently used. That means that the BufferedLogs directive that is implemented by mod_log_config will be ignored. As BufferedLogs isn’t document and is flagged as an experimental feature this shouldn’t be a problem in production environments. This doesn’t apply to the Apache 1.3 version of the module.
RotateLogsLocalTime On|Off
Normally the log rotation interval is based on UTC. For example an interval of 86400 (one day) will cause the logs to rotate at UTC 00:00. When this option is on, log rotation is timed relative to the local time.
RotateInterval <interval> [<offset>]
Set the interval in seconds for log rotation. The default is 86400 (one day). The shortest interval that can be specified is 60 seconds. An optional second argument specifies an offset in minutes which is applied to UTC (or local time if RotateLogsLocalTime is on). For example RotateInterval 86400 60 will cause logs to be rotated at 23:00 UTC.
