SyntaxHighlighter

Sunday, July 29, 2012

Log4J and Spring Integration

Log4J and Spring Integration


while playing around with an idea from a client recently, i started to build a very simple Spring Integration based Log4J appender.  the idea behind this pattern is that if i can put log messages into Spring Integration, then i can leverage all of it's abilities to manage different channel handlers, processing, etc.

the inspiration for the solution came from these sites;

http://www.coderanch.com/t/362833/Servlets/java/log-ServletContextListener

http://stackoverflow.com/questions/4400583/initializing-log4j-with-spring

here's the end code;

the appender;


the gateway (Spring Integration)


dumb little test point


the spring integration config (for testing)


how to wire it up in the application context


Note: the application contexts are separate - so anything you need in the Spring Integration for the Logger has to be setup there, not in the 'root' context

No comments:

Post a Comment