Hybrid View

  1. #1
    Ext JS Premium Member
    Join Date
    May 2009
    Location
    Barcelona (Spain)
    Posts
    218
    Vote Rating
    19
    pagullo will become famous soon enough pagullo will become famous soon enough

      7  

    Default Log4js-ext logging library published

    Log4js-ext logging library published


    I have developed a logging library form my own use, a-la log4j, for ExtJs. I decided to publish it under the GNU Lesser GPL so that the community can benefit from it.

    It provides the functionality and extensibility of the Java based log4j, plus a nice viewer that helps filter the logs, and the capability to log objects in highlighted json format. Of course, there is support for searching value in the logged objects, a must if you have tons of log output.

    This how the built-in log viewer looks like:

    log4js-ext-log-viewer.png

    Of course, there is support for logging to the browser console view, too.

    There is support for contextual logging, based on log4j's NDC concept.

    The library is fully tested, including almost 30 JsTestDriver automated tests.

    You can find it in http://code.google.com/p/log4js-ext/

    Best regards
    Last edited by pagullo; 17 Jul 2012 at 8:16 AM. Reason: Added more info
    Pedro Agulló, Barcelona (Spain)
    Agile team building, consulting, training & development
    DirectJNgine: http://code.google.com/p/directjngine - Log4js-ext: http://www.softwarementors.com/projects/p/log4js-ext/

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,884
    Vote Rating
    440
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    Very nice .. thank you for the contribution.

    Regards,
    Scott.

  3. #3
    Ext JS Premium Member
    Join Date
    Jun 2010
    Posts
    100
    Vote Rating
    10
    h.wagner@telekom.de will become famous soon enough

      0  

    Default


    Quote Originally Posted by pagullo View Post
    ...
    The library is fully tested, including almost 30 JsTestDriver automated tests.

    You can find it in http://code.google.com/p/log4js-ext/
    Very useful, thank you.

    Any plans to implement some transparent persistence/backend support too?
    E.g. maybe a servlet that would use Log4J directly?

    Thanks in advance.

  4. #4
    Ext JS Premium Member
    Join Date
    May 2009
    Location
    Barcelona (Spain)
    Posts
    218
    Vote Rating
    19
    pagullo will become famous soon enough pagullo will become famous soon enough

      1  

    Default


    Quote Originally Posted by h.wagner@telekom.de View Post
    Very useful, thank you.
    Thanks for your kind words

    Quote Originally Posted by h.wagner@telekom.de View Post
    Any plans to implement some transparent persistence/backend support too?
    E.g. maybe a servlet that would use Log4J directly?

    Thanks in advance.
    I plan to provide some kind of support for remote logging for my own use (don't know if a servlet...), so it will get into log4js-ext.

    Can't commit to a timeframe (main feature of "for-free" projects, you know), but at any rate it will be there in the near future (2 months at most).

    Regards,
    Pedro Agulló, Barcelona (Spain)
    Agile team building, consulting, training & development
    DirectJNgine: http://code.google.com/p/directjngine - Log4js-ext: http://www.softwarementors.com/projects/p/log4js-ext/

  5. #5
    Sencha User talha06's Avatar
    Join Date
    Jul 2009
    Location
    Turkey
    Posts
    303
    Vote Rating
    0
    talha06 is on a distinguished road

      0  

    Default


    Hi Pagullo,

    First of all, thank you so much for this great library, by the way this is really great idea.

    I started to use this useful library, I'm trying to log globally(I'll call logger at different sources). To do this, I created a global LogViewerWindow, then I created a logger. And finally I created another global LogViewerAppender. After that I'm calling logger functions to log. Everything is OK but I can only see logs at console. I want to see logs also at LogViewerWindow which I created for this aim.

    Here's the what I tried, I'll be happy if you can help me.
    Thanks in advance.
    With regards,
    T

    Global declaration:
    Code:
    var logViewer = Ext.create('Sm.log.LogViewerWindow', {	modal			: true,
    	closeAction		: 'hide',
    	id				: 'logViewer'
    });
    Sm.log.Logger.getRoot().setLevel( Sm.log.Level.INFO );
    var logger = Sm.log.Logger.getLogger('AppLogger');
    var logViewerAppender = new Sm.log.LogViewerAppender();
    logger.addAppender(logViewerAppender);
    logger.setLevel( Sm.log.Level.ALL );
    Sm.log.Logger.getRoot().addAppender(logViewerAppender);
    Calls from different sources:
    Code:
    logger.info('Application is initializing!');
    Code:
    logger.error( "An error occured!" );
    "People will never forget how you made them feel."
    linkedin.com/in/talhakabakus

  6. #6
    Ext JS Premium Member
    Join Date
    May 2009
    Location
    Barcelona (Spain)
    Posts
    218
    Vote Rating
    19
    pagullo will become famous soon enough pagullo will become famous soon enough

      2  

    Default


    Quote Originally Posted by talha06 View Post
    Hi Pagullo,

    First of all, thank you so much for this great library, by the way this is really great idea.
    Thanks

    In order to make thinks as easy as possible, the viewer window creates its own appender if it does not receive one.

    Therefore, you need not create a new appender, just pass it to your logger like this:

    Code:
    logger.addAppender( logViewer.getAppender() );
    Let me know if it works!

    ...

    As an aside, a practice I recommend is to create the appender as soon as possible, so that it can keep accumulating logs even though you can't show the viewer.

    The code to create the appender at the very beginning and attach it to the viewer later will look like this:

    Code:
    // First step in app after making sure required classes are loaded
    logViewerAppender = new Sm.log.LogViewerAppender();
    Sm.log.Logger.getRoot().addAppender(logViewerAppender);
    
    // ...
    
    Ext.onReady() {
       // ...
       logViewer = new Sm.log.LogViewerWindow(appender: logViewerAppender);
       logViewer.show();
    }
    The appender is smart enough to keep buffering logs until it can dump them to the log viewer.

    Regards,
    Pedro Agulló, Barcelona (Spain)
    Agile team building, consulting, training & development
    DirectJNgine: http://code.google.com/p/directjngine - Log4js-ext: http://www.softwarementors.com/projects/p/log4js-ext/

  7. #7
    Sencha User talha06's Avatar
    Join Date
    Jul 2009
    Location
    Turkey
    Posts
    303
    Vote Rating
    0
    talha06 is on a distinguished road

      0  

    Default


    @pagullo

    Thanks for your quick reply & care.

    Well, after I change code through your advice, now it works until I close the LogViewerWindow. When I try to re-open it, I only see the latest log.

    Here's the updated code:
    Global Declaration in app.js
    Code:
    // <<<<<<<<<<<<<<<<<<<<<<<<<<<<< LOG4JS INIT
    Sm.log.Logger.getRoot().setLevel( Sm.log.Level.INFO );
    var logger = Sm.log.Logger.getLogger('AppLogger');
    var logViewerAppender = new Sm.log.LogViewerAppender();
    logger.setLevel( Sm.log.Level.ALL );
    Sm.log.Logger.getRoot().addAppender(logViewerAppender);
    // LOG4JS INIT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    Calling from another source
    Code:
    logger.info('Loading users panel from');
    Thanks in advance..
    "People will never forget how you made them feel."
    linkedin.com/in/talhakabakus

  8. #8
    Touch Premium Member
    Join Date
    Nov 2011
    Posts
    124
    Vote Rating
    0
    JavascriptParrot is on a distinguished road

      0  

    Default


    Do you have a version for Sencha Touch?