150 likes | 165 Views
LogBox. Enterprise Logging. Brad Wood www.codersrevolution.com brad@bradwood.com. What is LogBox?. LogBox is an enterprise ColdFusion logging library designed to give you flexibility, simplicity and power when logging or tracing is needed in your applications.
E N D
LogBox Enterprise Logging Brad Wood www.codersrevolution.com brad@bradwood.com
What is LogBox? • LogBox is an enterprise ColdFusion logging library designed to give you flexibility, simplicity and power when logging or tracing is needed in your applications. • Inspired by Log4J (A Java logger made by Apache) • LogBox is part of the ColdBox Platform 3.0 or can be used as a stand-alone logging library.
Where Do I Use It? Log messages can come from anywhere in your application. • Logs from the framework (coldbox.system) • Specific component (com.example.order.orderService) • Package (com.example.security) • Ad-hoc locations (“nightly-scheduled-task”)
Where Do The Messages Go? Messages can be sent to any combination of appenders. LogBox ships with 14 appenders! • Files • Asynch files • Emails • Databases • Java sockets • Twitter • Web Services
Custom Logging Levels • Turn debugging of certain services on only when you need it (WireBox debugging) • Log information or debug messages only on dev server, but not in production • Only store logs from certain parts of your framework
Extending LogBox • Create custom appenders • Create custom layouts • Empower your CFC’s to create their own string representations for logging purposes.
Getting Started The minimum you need to get started: • Define root logger • Configure at least one appender • That’s it!
3 Ways To Configure LogBox • Configuration CFC (my favorite) • XML Config • Programmatic Config
Configuration CFC function configure(){ logBox = { // Define Appenders appenders = { coldboxTracer = { class=“path.to.appender" } }, // Root Logger root = { levelmax="INFO", levelMin=0, appenders="*" } }; }
XML Config <LogBox> <!-- Appender Definitions --> <Appender name="myconsole" class="path.to.appender" /> <!-- Root Logger --> <root levelMin="0" levelMax="4" appenders="*"> </LogBox>
Programmatic Config // Configuring some appenders and the root logger config.appender( name="Console", class="path.to.appender"); // root logger config.root( levelMin=config.logLevels.FATAL, levelMax=config.logLevels.INFO, appenders="Console");
Code Examples Base Functionality • Simple LogBox in a non-ColdBox app • Simple LogBox in a ColdBox app • Configure different logging levels • Configure different logging levels per environment • Configure multiple appenders • Configure multiple categories
Code Examples Customizing/extending LogBox • Write custom layout • Extra Info examples • Write custom appender
Questions? • Brad Wood • www.codersrevolution.com • brad@bradwood.com • Mailing List: groups.google.com/group/coldbox • Docs: wiki.coldbox.org/wiki/LogBox.cfm • Website: http://www.coldbox.org/