Warning: preg_replace(): Compilation failed: escape sequence is invalid in character class at offset 4 in /home/customer/www/theunixtips.com/public_html/wp-content/plugins/resume-builder/includes/class.resume-builder-enqueues.php on line 59

Application Logging Improvement – Part 3 Making it Readable

This is part three of my Application Logging improvement plan. So far I have discussed that log should be machine readable for application performance, management and monitoring. In this post I give an example of how to make the log readable to human (or make the log just like everyone has been used to seeing them). I am going to use vim to view the log files and have it configured so it knows how to handle the file with syntax etc.

First thing is configure vim to recognize the format. We create that in ftdetect directory. I use my home directory to store all of this but it can be moved to system directory or another directory for application’s usage and sourced it from there. Lets say our log files have “.mylog” as extension. So we create .vim/ftdetect/mylog.vim with following content.

au BufRead,BufNewFile *.mylog set filetype=mylog

Next is to create syntax file which will change log visually to make it more readable. By coloring errors or fatal messages in red it will keep the focus of viewer. Other things can go in different colors. So we create .vim/syntax/mylog.vim with following content. This will give some idea on what is going on and can be updated to suite ones taste.

That’s it folks.