Skip to content

Introduction to UnLog

aknauf edited this page Dec 8, 2016 · 2 revisions

UnLog is a logging framework with a difference. A traditional logging framework requires any client code that writes log events to depend on the framework. This means that any changes to the logging API will impact the client code in multiple places.

The following code is typical for traditional logging:

public static final Logger log = Logger.getLogger(MyClass.class.getName());
...
public void someMethod() {
    log.finest("Something happened");
}

UnLog approaches this differently:

public static final MyLog log = UnLog.createLogger(MyLog.class);
...
public void someMethod() {
    log.somethingHappened();
}

public interface MyLog {
    void somethingHappened();
}

So, with UnLog, the actual log statement is a call to an interface defined by the client code and not a call to the log framework itself. Most IDE's these days support intentional programming and will generate new log methods for you, so there is very little typing to do to maintain the extra log interface - and the interface is implemented by UnLog on the fly, (using a dynamic proxy,) so there is nothing further for the client developer to do there, either.

The actual text written to the log file is simply the method name, split into words according to camel case conventions.

Clone this wiki locally