02-16-2012 05:00 AM
I create a listener and I want to in logs information of the document.
Here is my code:
public class MyListener implements EventListener {
public void handleEvent(Event event) throws ClientException {
EventContext ctx = event.getContext();
DocumentEventContext docCtx = (DocumentEventContext) ctx;
// Here log doc title
}
}
What is best practive ?
02-16-2012 05:09 AM
Nuxeo uses the Log4J framework.
First you must add this static attribute:
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class MyListener implements EventListener {
private static final Log log = LogFactory.getLog(MyListener.class);
And use it to log your messages:
log.info("your message");
Choose a log level between fatal, error, warn, info, debug and trace.
Please see that thread and How to configure Nuxeo logging documentation.
Logging SomeException will look like:
catch (SomeException e) {
log.error(String.format("Failed with transition %s on doc %s", transition, doc.getId), e);
}
Important: don't let the default logging suggested by your IDE:
e.printStackTrace();
02-16-2012 05:09 AM
Nuxeo uses the Log4J framework.
First you must add this static attribute:
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class MyListener implements EventListener {
private static final Log log = LogFactory.getLog(MyListener.class);
And use it to log your messages:
log.info("your message");
Choose a log level between fatal, error, warn, info, debug and trace.
Please see that thread and How to configure Nuxeo logging documentation.
Logging SomeException will look like:
catch (SomeException e) {
log.error(String.format("Failed with transition %s on doc %s", transition, doc.getId), e);
}
Important: don't let the default logging suggested by your IDE:
e.printStackTrace();
Attention: Blogs & Forums are in READ-ONLY mode from Oct 9-19 as we transition to our new platform. Learn more.
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.