cancel
Showing results for 
Search instead for 
Did you mean: 

printing to console from javascript in dashlet?

targa2000
Champ in-the-making
Champ in-the-making
how do we print to the console from the javascript in a dashlet?
8 REPLIES 8

mrogers
Star Contributor
Star Contributor
Which console ?   The server's or the browser's.

If you want to print on the browser's console then you will have to write a java script function that runs on the browser.

targa2000
Champ in-the-making
Champ in-the-making
both.

targa2000
Champ in-the-making
Champ in-the-making
how about to the tomcat console that alfresco is deployed to?

targa2000
Champ in-the-making
Champ in-the-making
WEB-INF|classes|log4j.properties, set log4j.logger.org.alfresco.repo.jscript to DEBUG. logger.log statements in js go to catalina.out.

mikeh
Star Contributor
Star Contributor
For client-side JavaScript, you can enable the log4javascript module…

First, create a file called share-config-custom.xml in the tomcat/shared/classes/alfresco/web-extension folder. If you're using Tomcat 6, then make a note of the shared.loader property change you may need to make, detailed here: http://wiki.alfresco.com/wiki/Install_Tomcat6

Into share-config-custom.xml, copy the following relevant section of the share-config.custom.xml.sample file:
<alfresco-config>

   <!– Global config section –>
   <config replace="true">
      <flags>
         <!–
            Developer debugging setting to turn on DEBUG mode for client scripts in the browser
         –>
         <client-debug>true</client-debug>

         <!–
            LOGGING can always be toggled at runtime when in DEBUG mode (Ctrl, Ctrl, Shift, Shift).
            This flag automatically activates logging on page load.
         –>
         <client-debug-autologging>false</client-debug-autologging>
      </flags>
   </config>

</alfresco-config>

Shutdown and restart Tomcat. This will put Share into debug mode. You can then use the key sequence Ctrl, Ctrl, Shift, Shift to bring up the log4javascript debugging window. If this fails to pop-up, you're probably using Internet Explorer, so you can add "?log=on" or "&log=on" to the url to achieve the same thing (or set the client-debug-autologging flag to true in the config above).

In your JavaScript code, you can then use the Alfresco.logger.debug/info/warn/error/fatal() methods to output a message, e.g.
Alfresco.logger.debug("DL_onHistoryManagerReady", "changeFilter =>", this.options.initialFilter);

Thanks,
Mike

zengqingyi12
Champ in-the-making
Champ in-the-making
I just do as what you said, but nothing show up in the console, what's up ?
I am using alfresco 3.3 + tomcat 6 + Firefox
Thanks

mikeh
Star Contributor
Star Contributor
What *exactly* did you do? Do you see the log4javascript window?

Thanks,
Mike

zengqingyi12
Champ in-the-making
Champ in-the-making
I don't see any log4javascript windows, I only show the following debug windows:
alfresco web-tier javascript debugger
alfresco repository javascript debugger.