How to enable javascript logging (Alfresco community 5.2)

cancel
Showing results for 
Search instead for 
Did you mean: 
kenneth-venken
Active Member

How to enable javascript logging (Alfresco community 5.2)

Jump to solution

Hi,

I'm trying to log a message from a javascript file: my-tasks.js. I'm using the following code inside an Alfresco Share amp:

Alfresco.logger.warn("Kenneth Venken has succesfully logged a warning");

I've enabled client-debug in share-config.xml (Debug menu was added to main menu) but nothing is shown in my console or in any other log file. I've also set the log4j properties to:

# Web Framework
log4j.logger.org.springframework.extensions.webscripts=info
log4j.logger.org.springframework.extensions.webscripts.ScriptLogger=debug
log4j.logger.org.springframework.extensions.webscripts.ScriptDebugger=info

Where are these Alfresco.logger messages logged and what should I do to enable them?

 
 
 
 
 
1 Solution

Accepted Solutions
kenneth-venken
Active Member

Re: How to enable javascript logging (Alfresco community 5.2)

Jump to solution

So i found the solution. I had to enable client-debug in C:\alfresco-community\tomcat\shared\classes\alfresco\web-extension\share-config-custom.xml

   <!-- 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>true</client-debug-autologging>
      </flags>
   </config>

After a restart of tomcat the debug menu enabled and a log4javascript popup window showed up

 

View solution in original post

6 Replies
cristinamr
Advanced

Re: How to enable javascript logging (Alfresco community 5.2)

Jump to solution

Hi!

As a workaround you can use:

 

logger.system.out("Your message");

 

You can see your message in tomcat/logs/catalina.out or if you are using Alfresco as a service, you will be able to find it under alfrescotomcat-stdout.log

Note: client-debug must be enabled

Or you would have to configure your log4j properties using  OOTBee Support Tools console add-on (even you have a javasript console that you can use too).

Cheers!

--
VenziaIT: helping companies since 2005! Our ECM products: AQuA & Seidoc
kenneth-venken
Active Member

Re: How to enable javascript logging (Alfresco community 5.2)

Jump to solution

Ok, so i don't see my log message showing up in tomcat/logs/catalina.2021-09-01.log or tomcat/logs/alfrescotomcat-stdout.2021-09-01.log  (Nor is there a catalina.out file and i have client-debug enabled.)

Using logger.system.out('My message') results in a console error message: logger is undefined.

If I type Alfresco.logger.isDebugEnabled() in the console it returns false. Is this an indication that some settings are wrong for debug to work? I have no idea what to try next, any help is much appreciated.

If i go to /share/page/api/javascript/debugger it says that alfresco javascript debugger is currently disabled. If i press the enable button i get a 500 -internal error.

 
 
 
cristinamr
Advanced

Re: How to enable javascript logging (Alfresco community 5.2)

Jump to solution

I have the feeling that the problem is were are you "enabling" the debug. Could you please give us the path of the files that you modified and which lines did you added?

--
VenziaIT: helping companies since 2005! Our ECM products: AQuA & Seidoc
kenneth-venken
Active Member

Re: How to enable javascript logging (Alfresco community 5.2)

Jump to solution

C:\alfresco-community\tomcat\webapps\share\WEB-INF\classes\alfresco\share-config.xml:

   <!-- Global config section -->
   <config>
      <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>true</client-debug-autologging>

         <!--
            When this is set to true any Aikau based errors will be posted back to the server and 
            captured by the server side logging. This can be useful to detect when errors occur in 
            a users browser -->
         <post-client-debug>true</post-client-debug>
      </flags>
When i come to think about it, changing the client-debug setting to true didn't actually show the menu. I had to go to page/modules/deploy and add the Debug Enabler Extension. After this, the menu showed up
 
 
 
kenneth-venken
Active Member

Re: How to enable javascript logging (Alfresco community 5.2)

Jump to solution

So i found the solution. I had to enable client-debug in C:\alfresco-community\tomcat\shared\classes\alfresco\web-extension\share-config-custom.xml

   <!-- 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>true</client-debug-autologging>
      </flags>
   </config>

After a restart of tomcat the debug menu enabled and a log4javascript popup window showed up

 
cristinamr
Advanced

Re: How to enable javascript logging (Alfresco community 5.2)

Jump to solution

I'm glad you have resolved it ^_^

Cheers!

--
VenziaIT: helping companies since 2005! Our ECM products: AQuA & Seidoc