cancel
Showing results for 
Search instead for 
Did you mean: 

where does logger.log write to?

sharifu
Confirmed Champ
Confirmed Champ
I have set up js debugging and i cannot seem to find out where it logs to
5 REPLIES 5

afaust
Legendary Innovator
Legendary Innovator
Hello,

logger.log logs to the org.alfresco.repo.jscript.ScriptLogger in Log4J configuration. By default, this will land in catalina.out and alfresco.log, if DEBUG level is enabled.

Regards
Axel

sharifu
Confirmed Champ
Confirmed Champ
In ./tomcat/webapps/share/WEB-INF/classes/log4j.properties i have set the following


log4j.logger.org.alfresco.repo.jscript=debug
log4j.logger.org.alfresco.repo.jscript.ScriptLogger=debug


When i browse in the browser i tried ctrl + ctrl + shift + shift

I do not see any logging of my own.

I have set my script to execute on newly created items in the share. The following is my script.


logger.log("whatever");

var thirdParties = document.properties["sp:thirdParties"];
var location = document.properties["sp:location"];
var responsibleEmp = document.properties["sp:responsibleEmp"];
var contractRef = document.properties["sp:contractRef"];
var effectiveDate = document.properties["sp:effectiveDate"];
var mctype = document.properties["sp:mctype"];


var sourceFile = document;
//var sourceFolder = document.parent;
var targetFolder = "";
var success = true;

//Check to see if values are null
if( thirdParties == null || location == "" || responsibleEmp == null || contractRef == null || effectiveDate == null  || location.toString() != "UK" || mctype == null ){
   success = false;
   
}else{
   var effectiveDate = new Date ( document.properties["sp:effectiveDate"] );
   
   //Check if folder exist
   if(checkFolderExists(location, effectiveDate )){
      targetFolder = space.parent.childByNamePath(location.toString()).childByNamePath("Contracts").childByNamePath(effectiveDate.getFullYear().toString()).childByNamePath("MLA and Supplement");
      
   }else{
      success = false; // do not move doc no folder exists
   }
}

if(success){
   var targetFile = targetFolder.childByNamePath(document.name);
   
   if(targetFile == null){
      sourceFile.move(targetFolder);
   }else{
      var targetFileWorkingCopy = targetFile.checkout();
      targetFileWorkingCopy.content = sourceFile.content;
      targetFileWorkingCopy.checkin("",false);
      sourceFile.remove();
   }
}

/**   Function checks if year folder exists if not then it creeates it
*   @param String location of created doc
*   @param Date effectiveDate entered in metadata
*/
function checkFolderExists(location, effectiveDate){

   if( !space.parent.childByNamePath(location.toString()).childByNamePath("Contracts").childByNamePath(effectiveDate.getFullYear().toString()) ){      
      space.parent.childByNamePath(location.toString()).childByNamePath("Contracts").createFolder( effectiveDate.getFullYear().toString() ); //create year folder
      
      if( !space.parent.childByNamePath(location.toString()).childByNamePath("Contracts").childByNamePath(effectiveDate.getFullYear().toString()).childByNamePath("MLA and Supplement") ){
         space.parent.childByNamePath(location.toString()).childByNamePath("Contracts").childByNamePath(effectiveDate.getFullYear().toString()).createFolder("MLA and Supplement"); // create supllement mla folde rin year folder      
      }
      
      return true;
      
   }else if( !space.parent.childByNamePath(location.toString()).childByNamePath("Contracts").childByNamePath(effectiveDate.getFullYear().toString()).childByNamePath("MLA and Supplement") ) {
   
      space.parent.childByNamePath(location.toString()).childByNamePath("Contracts").childByNamePath(effectiveDate.getFullYear().toString()).createFolder("MLA and Supplement"); // create supllement mla folde rin year folder      
   
   }else if ( space.parent.childByNamePath(location.toString()).childByNamePath("Contracts").childByNamePath(effectiveDate.getFullYear().toString()).childByNamePath("MLA and Supplement") ) {
      return true;
      
   }else{
      return false;
   }

}



The problem I am having with this script is; it is not moving the file once I save it but after I have browsed out of the folder, and as mentioned i cannot seem to find where it is logging and I have the logging in my terminal window open and running using
tail -f /opt/alfresco-4.0.d/tomcat/logs/catalina.out /opt/alfresco-4.0.d/alfresco.log

afaust
Legendary Innovator
Legendary Innovator
Hello,

for your script you need to configure the /webapps/alfresco/WEB-INF/classes/log4j.properties not the Share one, as your script runs on the Repository, not the Share tier.

Regards
Axel

sharifu
Confirmed Champ
Confirmed Champ
I have updated and restarted. I still cannot locate where it is being logged

logger.log("whatever")   from my script does not appear anywhere


found it thanks

Where you find it ? I'm with the same problem.