Tag Archives: Log

Simple log file archiving

Some ESB servers at work produce log files for each day, and they can grow quite large. In addition the log directory becomes annoyingly full which makes it a bit “blah” to grep for recent stuff. So I figured I could save some space by compressing them.

Decided to experiment a bit and created a simple little script to archive the log files for certain months and figured I might as well share it. Especially since it might be handy to learn from later when I’ve forgotten how I did it 😛

Continue reading Simple log file archiving

PHP: Tail tackling large files

Needed a function that could get me the last N lines of a log file. Wanted it to be efficient and not dependent on anything other than my code.

Found some versions, but they were either a bit messy or depended on unstable arithmetic (where filesize is greater than PHP_INT_MAX). So, I decided to take on the challenge and try to write one myself. Nice little exercise 🙂

Continue reading PHP: Tail tackling large files