What is an appropriate way to separate lifecycle events in the logging system?
        Posted  
        
            by Hanno Fietz
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Hanno Fietz
        
        
        
        Published on 2010-03-12T14:26:36Z
        Indexed on 
            2010/03/12
            14:27 UTC
        
        
        Read the original article
        Hit count: 248
        
I have an application with many different parts, it runs on OSGi, so there's the bundle lifecycles, there's a number of message processors and plugin components that all can die, can be started and stopped, have their setup changed etc.
I want a way to get a good picture of the current system status, what components are up, which have problems, how long they have been running for etc. I think that logging, especially in combination with custom appenders (I'm using log4j), is a good part of the solution and does help ad-hoc analysis as well as live monitoring.
Normally, I would classify lifecycle events as INFO level, but what I really want is to have them separate from what else is going on in INFO. I could create my own level, LIFECYCLE.
The lifecycle events happen in various different areas and on various levels in the application hierarchy, also they happen in the same areas as other events that I want to separate them from. I could introduce some common lifecycle management and use that to distinguish the events from others. For instance, all components that have a lifecycle could implement a particular interface and I log by its name.
Are there good examples of how this is done elsewhere? What are considerations?
© Stack Overflow or respective owner