Thing which seemed very Thingish inside you is quite different when it gets out into the open and has other people looking at it

Tuesday, June 26, 2012

Monitor your application with system logs !!!


Tired of finding an issue with a current running application??? Your application started giving unexpected behavior and can’t figure out why? .. Cannot monitor your application properly? THEN LOGGING IS YOUR SOLUTION!!!!
 
Why Logging ???

Logging is a way of storing information about events happening during a program execution. Logging can be very useful when it comes to identify the event flow/ program execution or unexpected behavior of an execution such as errors/exceptions (error tracking) and it can be also useful when it comes to monitor performance.  Almost every developer use Logging!!! Even if they don’t use a special framework to do logging. For instance even if you are not using a particular logging frame work you most probably be using  system.printline in order to track  useful information and print them on the console so that you can monitor your application’s behavior and it’s current activities.

Importance of using a Logging Framework ?

However, using a logging frame work is a major plus point. Mostly because logs  are the very lifeline of your production application and it should not be taken lightly or as an afterthought. For example let’s say you don’t use logging at all and your application is out of development environment and your application is giving an unexpected behavior, it will be like finding a needle in a haystack to figure out what’s gone wrong in your application if you don’t use proper logging using a proper logging framework. 
  
Of cause using a logging framework is a plus point when it comes to enterprise applications. Because by using a logging frame work you can easily define log levels and filter logs accordingly. Further, when it comes to distributed applications (such as web/remote application) logging is a very crucial task because system administrators always needs to keep eye of what happening and  always need to see the logs for a given period of time. So filtering logs and viewing logs is also very important. This is why Logging has become the most frequent implementation of the Monitoring attribute and also in most cases it is the only implementation of monitoring (Mainly because it is the most easiest thing in the world for a busy developer to just put lnfor.log() in the code. However, apart from the ease of use logging frameworks also allow you to send logs to many different parties such as file systems, consoles, and databases. Which makes it easy for a system admin to filter logs from timestamp, log levels, and log messages.

Drawbacks of Logging

Even though, logging is a very important thing when it comes to developing application there is such thing  as too much logging and it’s important to know how to log efficiently.  Before we look into that lets see the common draw backs of bad logging.
Performance – There can be performance hit in your application if you don’t put the logs in the right way. One thing is if you have too many logs at unwanted places it can be a major performance hit and also it will reduce the speed of your application. And also pollute and increase the size of your code.

Scalability issues – When you log unwanted information or not have proper log levels in your application you might end up having huge log files. And it will increase the size of your log files. And it can eat up your software and hard ware resources.

Security – Logging can be security vulnerability because logs can carry security information such as passwords of user accounts and other sensitive information which may expose a system vulnerabilities.
These are very important points because our ultimate goal is to have efficient application which can be monitored efficiently at all time.

 
Best Practices of Logging
Therefore I would like to list down some of the best practices when it comes for logging however, I would like to discuss them in details in my next blog post.


  1. Use an appropriate logging framework depending on your need - The proper selection of logging frame work will lead you to store and filter your information in an orderly fashion)
  2. Proper use of Log levels - There are different levels of log levels choosing the right level at the right time can increase the performance and the scalability of your application.
  3. Do Not Log unwanted information – Always make sure you know what you are logging and also make sure logging will not give side effects to your application. (Make sure you avoid null pointer exception while logging ;) ) And ALWAYS be concise and descriptive when you log 
  4.  Make sure you use your own pattern. Logging frameworks let you design your own pattern layout which helps you filter your logs in an efficient manner. Make sure you use features of logging frame work when its needed.








1 comment:

  1. This comment has been removed by a blog administrator.

    ReplyDelete