|
XydraLog
The holy grail of most code in Xydra is simple portability between plain Java, AppEngine and usage via GWT as JavaScript in the browser. Until now, there was no logging framework being able to do that. UPDATE: It looks like GWT 2.1 brings java.util.logging which also works on GAE The XydraLog mimics the SLF4j API, although only the very easy parts. At runtime, it re-uses the great gwt-log project, if running in GWT. In fact, if you use GWT, you must use gwt-log as well -- or get a nasty error from XydraLog. UsageMaven dependency: <dependency> <groupId>org.xydra</groupId> <artifactId>log</artifactId> <version>0.0.1</version> </dependency> Configuration in GWT projectsFor your GWT projects also add: <dependency> <groupId>com.google.code.gwt-log</groupId> <artifactId>gwt-log</artifactId> <version>2.6.2</version> </dependency> In the module add <!-- Import the log module --> <inherits name='org.xydra.log.Xlog' /> Also add one of the configs described at http://code.google.com/p/gwt-log/wiki/GettingStarted -- e.g. this one: <!-- Import the gwt-log --> <inherits name="com.allen_sauer.gwt.log.gwt-log-OFF" /> <extend-property name="log_level" values="INFO" /> Using the loggerIn a class Person use private static final Logger log = LoggerFactory.getLogger(Person.class); And in methods use log.trace( ... );
log.trace( ..., exception );
log.debug, log.info, log.warn, log.error
if(log.isTraceEnabled()) {
// construct a complex string and log it
}Sample CodeA sample project using XydraLog in a GWT project can be found here in our SVN For DevelopersThe full source code is in this svn at /trunk/org.xydra.log Features
Roadmap / Not-Yet-Features
|
► Sign in to add a comment