My favorites | Sign in
Project Home Downloads Issues Source
Project Information
Members

Aspect that allow you mark method with annotaiton and get its calls/retunrs traces in SL4J logs.

For example, instead of such method in args trace logging:

    @Override
    @Transactional(value = "incidents", readOnly = true)
    public CasesPage getHistoryFor(
        @NotNull ClientId clientId,
        @Nullable SubscriberId subscriberId,
        @Nullable Subject subject,
        @Nullable Category category,
        int offset, int limit
    ) {
        if (LOG.isTraceEnabled()) {
            LOG.trace("getHistoryFor(");
            LOG.trace(" clientId={},", clientId);
            LOG.trace(" subscriberId={},", subscriberId);
            LOG.trace(" subject={}, ", subject);
            LOG.trace(" category={}, ", category);
            LOG.trace(" offset={}, ", offset);
            LOG.trace(" limit={}", limit);
            LOG.trace(")");
        }
        
        //method body (business logic)...

you could mark method with annotaion:

    @Override
    @Transactional(value = "incidents", readOnly = true)
    @Trace(traceArgs = true, traceRetrunValue = true)
    public CasesPage getHistoryFor(
        @NotNull ClientId clientId,
        @Nullable SubscriberId subscriberId,
        @Nullable Subject subject,
        @Nullable Category category,
        int offset, int limit
    ) {
        
        //method body (business logic)...

and method calls will produce such trace in class's log (toString() of args and returns are used):

2011-10-07 13:23:47,250 TRACE getHistoryFor(Client{1,22131},SubscriberId{2,1212121},Subject{id=12, name="12"}, INFORMATION, 1, 100)
2011-10-07 13:23:47,274 TRACE getHistoryFor() => CasesPage{size=12}

See HowToSetup for configuration details.

Powered by Google Project Hosting