cancel
Showing results for 
Search instead for 
Did you mean: 

Overrule Alfresco's log4j.properties

kbonnet
Champ in-the-making
Champ in-the-making
It seems like whatever i try, the log4j.properties in de WEB-INF/classes directory is taking precedence above my log4j.properties in my [tomcat_home]/shared/classes directory.

I would like to be able to manage logging properties without being suprised that everything jumps to default when i install a new module or do anything else with the alfresco.war.

Does anyone have tips how to use another log4j.properties out of the alfresco.war area?

Thanks!

Kind regards,

Koen Bonnet
6 REPLIES 6

pmonks
Star Contributor
Star Contributor
Unfortunately because of the way Log4J loads its own properties file, the standard Alfresco override mechanism doesn't work for those files.  In 2.2 this has been addressed (see http://wiki.alfresco.com/wiki/Developing_an_Alfresco_Module#log4j.properties) and in earlier versions the code attached to http://issues.alfresco.com/browse/AR-1744 can be used (albeit it's a lot less sophisticated as a solution than the 2.2 code).

Cheers,
Peter

kbonnet
Champ in-the-making
Champ in-the-making
Hi Peter,

Thanks for your prompt reply. My main problem is not the switching back to the default log levels. I could live with that, especially now i've read about the *-log4j.properties, introduced in version 2.2.

For me, the most annoying is the fact that the alfresco.log file is specified without a further path. On my system (Ubuntu 7.04/Tomcat 5.5) this has the effect that Tomcat is trying to create an alfresco.log file in the directory i'm currently in when restarting. If the tomcat user has sufficient right i end up with a log file in a spot i don't want it, or i don't have logging at all because the tomcat user doens't have the rights to create the file there.

The solution you suggest first (via log4j.properties in the module pack) will not solve the problem of the mail alfresco.log file name and path, right?

The second solution sounds nice to me, although you say it's a workaround. But if i read the issue, i get the feeling that this functinality of providing a *-log4j.properties is in the main code of the Enterprise version now. Not available to 2.9 Community users?

Thanks,

Koen

pmonks
Star Contributor
Star Contributor
The location of the alfresco.log file is specified in log4j.properties - feel free to put an absolute path in there if that better meets your needs.  The problem is that currently (pre-2.2), there's no clean way to override the log4j.properties file - you have to modify the version in the alfresco.war file directly, or resort to the "re-initialise" approach implemented in the class attached to AR-1744.

The logic that was added to 2.2 to allow log4j.properties overrides will be merged into the community (2.9) branch at some point (and may already be there in the nightly builds; I'm not sure) - it's just that we don't immediately merge changes between branches (whether edition branches or version branches).  Our goal is to keep the Enterprise and Community editions functionally identical, however the reality is that merging is not cost-free, so changes may take a little time to propagate (I should also mention that this applies in both directions - there are some things in community that take time to appear in enterprise, as well as the reverse situation).

Cheers,
Peter

mikeh
Star Contributor
Star Contributor
This update was merged from v2.2 to HEAD on 10th March so will be available from a nightly build after that date.

Thankss,
Mike

kbonnet
Champ in-the-making
Champ in-the-making
Thanks, you both!

gilles
Champ in-the-making
Champ in-the-making
I put a dev-log4j.properties in  $TOMCAT_HOME/shared/classes/alfresco/extension/ , but the WEB-INF/classes/log4j/properties is still used by the application. What should I check in a 2.9b CE to have the dev-log4j.properties taken into account?
Thanks,
Gilles