<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic I&amp;apos;m new JAVA developer, I want to log in my code. What is the best practice in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/i-apos-m-new-java-developer-i-want-to-log-in-my-code-what-is-the/m-p/317281#M4282</link>
    <description>&lt;P&gt;I create a listener and I want to in logs information of the document.&lt;/P&gt;
&lt;P&gt;Here is my code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;public class MyListener implements EventListener {
    public void handleEvent(Event event) throws ClientException {
        EventContext ctx = event.getContext();
        DocumentEventContext docCtx = (DocumentEventContext) ctx;
        // Here log doc title
    }    
}
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What is best practive ?&lt;/P&gt;</description>
    <pubDate>Thu, 16 Feb 2012 10:00:29 GMT</pubDate>
    <dc:creator>Benjamin_Jalon1</dc:creator>
    <dc:date>2012-02-16T10:00:29Z</dc:date>
    <item>
      <title>I&amp;apos;m new JAVA developer, I want to log in my code. What is the best practice</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/i-apos-m-new-java-developer-i-want-to-log-in-my-code-what-is-the/m-p/317281#M4282</link>
      <description>&lt;P&gt;I create a listener and I want to in logs information of the document.&lt;/P&gt;
&lt;P&gt;Here is my code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;public class MyListener implements EventListener {
    public void handleEvent(Event event) throws ClientException {
        EventContext ctx = event.getContext();
        DocumentEventContext docCtx = (DocumentEventContext) ctx;
        // Here log doc title
    }    
}
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What is best practive ?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2012 10:00:29 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/i-apos-m-new-java-developer-i-want-to-log-in-my-code-what-is-the/m-p/317281#M4282</guid>
      <dc:creator>Benjamin_Jalon1</dc:creator>
      <dc:date>2012-02-16T10:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: I&amp;apos;m new JAVA developer, I want to log in my code. What is the best practice</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/i-apos-m-new-java-developer-i-want-to-log-in-my-code-what-is-the/m-p/317282#M4283</link>
      <description>&lt;P&gt;Nuxeo uses the Log4J framework.&lt;/P&gt;
&lt;P&gt;First you must add this static attribute:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt; 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);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And use it to log your messages:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;PRE&gt;&lt;CODE&gt;log.info("your message");
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Choose a log level between fatal, error, warn, info, debug and trace.&lt;/P&gt;
&lt;P&gt;Please see &lt;A href="http://answers.nuxeo.com/questions/685/what-is-the-mechanism-for-logging-errorwarning-information"&gt;that thread&lt;/A&gt; and &lt;A href="http://doc.nuxeo.com/display/KB/How+to+configure+Nuxeo+logging"&gt;How to configure Nuxeo logging documentation&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;Logging SomeException will look like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;catch (SomeException e) {
    log.error(String.format("Failed with transition %s on doc %s", transition, doc.getId), e);
}
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;EM&gt;Important&lt;/EM&gt;: don't let the default logging suggested by your IDE:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;e.printStackTrace();
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Feb 2012 10:09:20 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/i-apos-m-new-java-developer-i-want-to-log-in-my-code-what-is-the/m-p/317282#M4283</guid>
      <dc:creator>Benjamin_Jalon1</dc:creator>
      <dc:date>2012-02-16T10:09:20Z</dc:date>
    </item>
  </channel>
</rss>

