I’m looking into using a javascript logging framework in my app.
I quite like the look of log4javascript (http://log4javascript.org/) but I have one requirement which I’m not sure that it satisfies.
I need to be able to ask the framework for all messages which have been logged.
Perhaps I could use an invisible InPageAppender (http://log4javascript.org/docs/manual.html#appenders) to log to a DOM element, then scrape out the messages from that DOM element – but that seems pretty heavy.
Perhaps I need to write my own “InMemoryAppender”?
There’s an
ArrayAppenderused in log4javascript’s unit tests that stores all log messages it receives in an array accessible via itslogMessagesproperty. Hopefully it should show up in the main distribution in the next version. Here’s a standalone implementation:Example use: