Hybrid View
-
3 Jul 2012 5:01 AM #1
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 regardsLast 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/
-
3 Jul 2012 7:53 AM #2
Very nice .. thank you for the contribution.
Regards,
Scott.
-
3 Jul 2012 11:04 PM #3
-
4 Jul 2012 12:35 AM #4
Thanks for your kind words

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/
-
8 Jul 2012 5:59 AM #5
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:
Calls from different sources: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);
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
-
8 Jul 2012 7:45 AM #6
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:
Let me know if it works!Code:logger.addAppender( logViewer.getAppender() );
...
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:
The appender is smart enough to keep buffering logs until it can dump them to the log viewer.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(); }
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/
-
8 Jul 2012 8:22 AM #7
@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
Calling from another sourceCode:// <<<<<<<<<<<<<<<<<<<<<<<<<<<<< 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 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Thanks in advance..Code:logger.info('Loading users panel from');"People will never forget how you made them feel."
linkedin.com/in/talhakabakus


Reply With Quote

