Unfortunatelly, the Alfresco log files can end up in various different locations depending on OS and how you choose to start Alfresco. Even more unfortunate is that Alfresco has not provided an easy way to set the log file directory. In general the logs will show up in the current working directory for Alfresco. There are a couple of different options on how to change the location of the log files.
Option 1 – Change the working directory (PWD)
In both Windows and Linux, if you are starting Alfresco by invoking the startup scripts, i.e. startup.bat/startup.sh or alfresco.sh, the easiest way is to ”cd” yourself to the directory where you want the logs to end up and invoke the script from there. For example, in Linux you can add the following line ”cd /opt/alfresco” right before the line that says ”ERROR=0” in alfresco.sh.
In Windows, if you start Alfresco using the script file, you can solve this by setting the CATALINA_HOME environment variable to the tomcat folder, e.g. CATALINA_HOME=c:projectsserversalfrescotomcat. Then run startup.bat from the location where you want the log files, e.g. in the Alfresco root as ”tomcatbinstartup.bat”, or you can create another bat file that ”cd”s into the root and makes the call to startup.bat from there.
If you run Alfresco as a Windows service it’s a little trickier but still quite easy. Modify the Tomcat Windows service using tomcat7w.exe, as described in this blog post. Once you have the edit service GUI open, go to the tab called ”Startup”. Add a path to the Working Path field, e.g. ”C:projectsserversalfresco”. Click Apply and OK.
Option 2 – Change the log file setting in log4j.properties
Alfresco, Share, and Solr all have a log4j.properties file respectively. They are located in alfresco/tomcat/webapps/alfresco|share|solr/WEB-INF/classes. You can change the name and location of the log file by modifying the following property ”log4j.appender.File.File=*.log” . You can change this to some other absolute or relative path.
It’s a bad idea to change those files directly, since the changes will be overwritten the next time you redeploy your AMPs. In Share there is no override mechanism so for Share you will have to live with redoing the change with every new deploy (or set up and package such a mechanism yourself using Log4JHierarchyInit.java as a start but that is a *lot* of work just for a log file location). For Alfresco you should copy the original log4j.properties to TOMCAT-HOME/shared/classes/alfresco/extension/alfresco-log4j.properties and make your changes there. For Solr you should make your changes in alfresco/alf_data/solr/log4j-solr.properties.
Since there is no override mechanism for Share logs and we want a coherent solution that works the same way, I recommend choosing Option 1 above and solve the problem by changing the working directory.