Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Logging custom attributes in log4j.
I googled and surfed the forum for a long time, but I couldn't find how to log custom attributes by log4j in Vaadin 7.
Usually this goal is accomplished using MDC.put('key') and MDC.remove('key') at the beginning and end of a transaction. In Vaadin 6 there was a TransactionListener interface that could be implemented by a class extending Application, where we could trap begin and end of transaction.
Now, I cannot understand how to do the same in Vaadin 7: can anyone help me?
Vaadin uses java.util.logging, not log4j.
Thus, log4j specific APIs do not affect the logging performed by Vaadin - though you should be able to configure your system to forward logs from java.util.logging to log4j, and perhaps that is what you were already doing with Vaadin 6.
As for intercepting the beginning and end of a request/transaction/..., this also depends on which level you want to intercept it. If you want to do this for all kinds of requests, overriding VaadinServlet.service() or using a servlet request listener (which has some limitations when using server push) are among the available options.
Following your advice, and reading thread 3214685, I could solve my problem extending VaadinServlet.
public static class Servlet extends VaadinServlet
protected VaadinServletService createServletService(DeploymentConfiguration deploymentConfiguration) throws ServiceException
VaadinServletService servletService = new VaadinServletService(this, deploymentConfiguration)
public void requestStart(VaadinRequest request, VaadinResponse response)
public void requestEnd(VaadinRequest request, VaadinResponse response, VaadinSession session)
super.requestEnd(request, response, session);