2

I´m working with share-amp-archetype trying to setup log4j for my module, where do I have to put log4j.properties?

I´ve tried in src/main/amp/config/alfresco/{moduleId} and it seems not work.

When in my javascript webscript controller write logger.log("I´m here!") nothing is logged, instead logger.warn("I´m here!") works fine.

In my source my files is (src/main/amp/config/alfresco/{moduleId})

log4j.logger.org.springframework.extensions.webscripts=info
log4j.logger.org.springframework.extensions.webscripts.ScriptLogger=debug
log4j.logger.org.springframework.extensions.webscripts.ScriptDebugger=off

/src/test/resources/log4j.properties

...
log4j.logger.org.springframework.extensions.webscripts=info
log4j.logger.org.springframework.extensions.webscripts.ScriptLogger=debug
log4j.logger.org.springframework.extensions.webscripts.ScriptDebugger=off
...

Note: searching for lo4j.properties in /target I can see 5 files!!

target\test-classes\lo4j.properties
target\test-classes\alfresco\module\{moduleId}\lo4j.properties
target\{moduleId}-war\WEB-INF\classes\lo4j.properties
target\{moduleId}-war\WEB-INF\classes\alfresco\module\share-asesorPlus\lo4j.properties
target\{moduleId}\config\alfresco\module\{moduleId}\lo4j.properties
timo.rieber
  • 3,727
  • 3
  • 32
  • 47
RURIA
  • 59
  • 4

1 Answers1

4

The locations you're mentioning seem to be taken from the Alfresco Repository extensions - logging guide, and not the Alfresco Share extensions section, which is why they're not working

As far as I can check/remember, Share doesn't actually have (out of the box) a context file defining extensions/modules log4j files to load.

As such, you first need to add a context file to your module with something like this in:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
  <bean id="log4JHierarchyInit" class="org.alfresco.repo.admin.Log4JHierarchyInit" init-method="init">
     <property name="extraLog4jUrls">
         <list>
           <value>classpath*:alfresco/module/*/log4j.properties</value>
         </list>
     </property>
   </bean>
</beans>

Pop that in a suitably named context file in your amp, then you can create a log4j properties file under config/alfresco/{moduleId}/ and have it used

(That snippet is taken from the Alfresco Repository war config, which does support module log4j files as standard. You need to bring a similar bean definition over to enable it in Share)

Gagravarr
  • 47,320
  • 10
  • 111
  • 156