이런 툴 없나요?

송지석의 이미지

로깅 하는 기능 말이죠
예를 들어
./a.out > log.txt
하면 로그가 log.txt에 기록되는데요
마치 syslog가 하듯이 가끔씩 예전 로그를 날려주는 툴이 있나요?
예를 들어
./a.out | logger --length=20480 -o log.txt
하면 20480byte(20KB)이상 되면 log를 rotate해주거나 날려주는 유틸리티 말이죠.
누군가 만들었음직 한데
어디 있을까요?

File attachments: 
첨부파일 크기
Binary Data flog-1.6-dsong.tar.gz3.27 KB
dotri의 이미지

음. 리다이렉션과 로그를 햇갈리시는듯하네요.
쉘에서 사용하는 '>' 는 로그를 남기는게 아니라.. 화면에 보여야 할 출력을 파일로 돌려주는겁니다.
말씀하시는 기능은... 출력이 일정 용량을 넘어가면 먼저 남겨진 출력부터 삭제하면서 출력파일 크기의 한계를 정하게 하고 싶으신것 같은데.. 프로그램 안에서 그렇게 처리해주지 않는 한 외부에서는 불가능할것같네요.

송지석의 이미지

리디렉션으로 로그를 남기려고 했죠. :-)
freshmeat에서 검색해보니 비슷한 프로그램이 있길래 수정해서 길이 제한을 걸어봤습니다.

댓글 첨부 파일: 
첨부파일 크기
Binary Data 0바이트
thinker0의 이미지

Apache bin 에있어요.

]$ apache/bin/rotatelogs --help
Usage: ./rotatelogs [-l] <logfile> <rotation time in seconds> [offset minutes from UTC] or <rotation size in megabytes>

Add this:

TransferLog "|./rotatelogs /some/where 86400"

or 

TransferLog "|./rotatelogs /some/where 5M"

to httpd.conf. The generated name will be /some/where.nnnn where nnnn is the
system time at which the log nominally starts (N.B. if using a rotation time,
the time will always be a multiple of the rotation time, so you can synchronize
cron scripts with it). At the end of each rotation time or when the file size
is reached a new log is started.