Change logs path

cancel
Showing results for 
Search instead for 
Did you mean: 
gsardisco
Member II

Change logs path

Jump to solution

I need some help to customize path for alfresco.log and share.log

I built alfresco 6.1 community with SDK 3.1 and deployed on Tomcat 8.5.

Share and Alfresco logging in tomcat root path:
<tomcat_home>/alfresco.log
<tomcat_home>/share.log

I want log files only under:
<tomcat_home>/logs/alfresco.log
<tomcat_home>/logs/share.log
and rolling, of course.

I tried to add to copy 
<tomcat_home>/webapps/alfresco/WEB-INF/classes/log4j.properties
 under
<tomcat_home>/shared/classes/alfresco/extension/custom-log4j.properties with:
log4j.appender.File.File=./logs/alfresco.log

This configuration created alfresco.log on startup, logging only "Ignoring script patch" and finally log under <tomcat_home>./logs

The best result (without initial log "Ignoring script patch"), if I run ../bin/startup.sh under <tomcat_home>./logs (I didn't understand this behavior)

What is the best way to configure alfresco.log? I think to add custom-log4j.properties, isn't it?

But, how to configure log path for share? Can I add configuration in SDK? Where?

Can you help me?

Thanks a lot.

1 Solution

Accepted Solutions
abhinavmishra14
Advanced

Re: Change logs path

Jump to solution

Are you using sdk 4.x or 3.x? For ACS6.x you should be using the sdk4.1 

You can create custom log file for alfresco, check this thread: https://hub.alfresco.com/t5/alfresco-content-services-forum/logs-file-in-sdk-4-1/m-p/301710#M21137

Custom log4j may not work for share so additionally, you can update the war files to have paths as "logs/alfresco.log, logs/share.log"

e.g:

./tomcat/webapps/share/WEB-INF/classes/log4j.properties:log4j.appender.File.File=logs/share.log
./tomcat/webapps/alfresco/WEB-INF/classes/log4j.properties:log4j.appender.File.File=logs/alfresco.log

If you are using sdk3.1 (which i have not tested to use it for ACS6.x), you can do ovelaying to update the war files (alfresco.war, share.war) with updated appender file paths. Checkout this thread for more on overlaying : https://hub.alfresco.com/t5/alfresco-content-services-forum/trying-to-generate-war-for-alfresco-and-...

If you are using SDK4.1 and docker, you can update the <yourcustomRepoModule>-platform-docker/src/main/docker/DockerFile to have following steps :

RUN sed -i "s|log4j.appender.File.File\=alfresco.log|log4j.appender.File.File\=logs/alfresco.log |g" $TOMCAT_DIR/webapps/alfresco/WEB-INF/classes/log4j.properties ;

example:

FROM ${docker.acs.image}:${alfresco.platform.version}

ARG TOMCAT_DIR=/usr/local/tomcat

USER root

# Copy Dockerfile to avoid an error if no JARs exist
COPY Dockerfile extensions/*.jar $TOMCAT_DIR/webapps/alfresco/WEB-INF/lib/

# Copy Dockerfile to avoid an error if no AMPs exist
COPY Dockerfile extensions/*.amp $TOMCAT_DIR/amps/
RUN java -jar $TOMCAT_DIR/alfresco-mmt/alfresco-mmt*.jar install \
              $TOMCAT_DIR/amps $TOMCAT_DIR/webapps/alfresco -directory -nobackup -force

RUN sed -i "s|log4j.appender.File.File\=alfresco.log|log4j.appender.File.File\=logs/alfresco.log |g" $TOMCAT_DIR/webapps/alfresco/WEB-INF/classes/log4j.properties ;
COPY alfresco-global.properties $TOMCAT_DIR/shared/classes/alfresco-global.properties COPY dev-log4j.properties $TOMCAT_DIR/shared/classes/alfresco/extension COPY disable-webscript-caching-context.xml $TOMCAT_DIR/shared/classes/alfresco/extension # Copy Dockerfile to avoid an error if no license file exists COPY Dockerfile license/*.* $TOMCAT_DIR/webapps/alfresco/WEB-INF/classes/alfresco/extension/license/ USER ${USERNAME}

for share, <yourcustomShareModule>-share-docker/src/main/docker/DockerFile:

FROM ${docker.share.image}:${alfresco.share.version}

ARG TOMCAT_DIR=/usr/local/tomcat

# Copy Dockerfile to avoid an error if no JARs exist
COPY Dockerfile extensions/*.jar $TOMCAT_DIR/webapps/share/WEB-INF/lib/

# Copy Dockerfile to avoid an error if no AMPs exist
COPY Dockerfile extensions/*.amp $TOMCAT_DIR/amps_share/
RUN java -jar $TOMCAT_DIR/alfresco-mmt/alfresco-mmt*.jar install \
              $TOMCAT_DIR/amps_share $TOMCAT_DIR/webapps/share -directory -nobackup -force

RUN sed -i "s|log4j.appender.File.File\=share.log|log4j.appender.File.File\=logs/share.log |g" $TOMCAT_DIR/webapps/share/WEB-INF/classes/log4j.properties ;

COPY share-config-custom.xml $TOMCAT_DIR/shared/classes/alfresco/web-extension

COPY log4j.properties $TOMCAT_DIR/webapps/share/WEB-INF/classes
COPY hotswap-agent.properties $TOMCAT_DIR/webapps/share/WEB-INF/classes

This will build the custom image with updated log path.

 

~Abhinav
(ACSCE, AWS SAA, Azure Admin)

View solution in original post

3 Replies
abhinavmishra14
Advanced

Re: Change logs path

Jump to solution

Are you using sdk 4.x or 3.x? For ACS6.x you should be using the sdk4.1 

You can create custom log file for alfresco, check this thread: https://hub.alfresco.com/t5/alfresco-content-services-forum/logs-file-in-sdk-4-1/m-p/301710#M21137

Custom log4j may not work for share so additionally, you can update the war files to have paths as "logs/alfresco.log, logs/share.log"

e.g:

./tomcat/webapps/share/WEB-INF/classes/log4j.properties:log4j.appender.File.File=logs/share.log
./tomcat/webapps/alfresco/WEB-INF/classes/log4j.properties:log4j.appender.File.File=logs/alfresco.log

If you are using sdk3.1 (which i have not tested to use it for ACS6.x), you can do ovelaying to update the war files (alfresco.war, share.war) with updated appender file paths. Checkout this thread for more on overlaying : https://hub.alfresco.com/t5/alfresco-content-services-forum/trying-to-generate-war-for-alfresco-and-...

If you are using SDK4.1 and docker, you can update the <yourcustomRepoModule>-platform-docker/src/main/docker/DockerFile to have following steps :

RUN sed -i "s|log4j.appender.File.File\=alfresco.log|log4j.appender.File.File\=logs/alfresco.log |g" $TOMCAT_DIR/webapps/alfresco/WEB-INF/classes/log4j.properties ;

example:

FROM ${docker.acs.image}:${alfresco.platform.version}

ARG TOMCAT_DIR=/usr/local/tomcat

USER root

# Copy Dockerfile to avoid an error if no JARs exist
COPY Dockerfile extensions/*.jar $TOMCAT_DIR/webapps/alfresco/WEB-INF/lib/

# Copy Dockerfile to avoid an error if no AMPs exist
COPY Dockerfile extensions/*.amp $TOMCAT_DIR/amps/
RUN java -jar $TOMCAT_DIR/alfresco-mmt/alfresco-mmt*.jar install \
              $TOMCAT_DIR/amps $TOMCAT_DIR/webapps/alfresco -directory -nobackup -force

RUN sed -i "s|log4j.appender.File.File\=alfresco.log|log4j.appender.File.File\=logs/alfresco.log |g" $TOMCAT_DIR/webapps/alfresco/WEB-INF/classes/log4j.properties ;
COPY alfresco-global.properties $TOMCAT_DIR/shared/classes/alfresco-global.properties COPY dev-log4j.properties $TOMCAT_DIR/shared/classes/alfresco/extension COPY disable-webscript-caching-context.xml $TOMCAT_DIR/shared/classes/alfresco/extension # Copy Dockerfile to avoid an error if no license file exists COPY Dockerfile license/*.* $TOMCAT_DIR/webapps/alfresco/WEB-INF/classes/alfresco/extension/license/ USER ${USERNAME}

for share, <yourcustomShareModule>-share-docker/src/main/docker/DockerFile:

FROM ${docker.share.image}:${alfresco.share.version}

ARG TOMCAT_DIR=/usr/local/tomcat

# Copy Dockerfile to avoid an error if no JARs exist
COPY Dockerfile extensions/*.jar $TOMCAT_DIR/webapps/share/WEB-INF/lib/

# Copy Dockerfile to avoid an error if no AMPs exist
COPY Dockerfile extensions/*.amp $TOMCAT_DIR/amps_share/
RUN java -jar $TOMCAT_DIR/alfresco-mmt/alfresco-mmt*.jar install \
              $TOMCAT_DIR/amps_share $TOMCAT_DIR/webapps/share -directory -nobackup -force

RUN sed -i "s|log4j.appender.File.File\=share.log|log4j.appender.File.File\=logs/share.log |g" $TOMCAT_DIR/webapps/share/WEB-INF/classes/log4j.properties ;

COPY share-config-custom.xml $TOMCAT_DIR/shared/classes/alfresco/web-extension

COPY log4j.properties $TOMCAT_DIR/webapps/share/WEB-INF/classes
COPY hotswap-agent.properties $TOMCAT_DIR/webapps/share/WEB-INF/classes

This will build the custom image with updated log path.

 

~Abhinav
(ACSCE, AWS SAA, Azure Admin)
gsardisco
Member II

Re: Change logs path

Jump to solution

Sorry, I confused my two project. I use SDK 4.1 to build ACS6.x.

I will try your suggestions.

Thanks! Smiley Happy

abhinavmishra14
Advanced

Re: Change logs path

Jump to solution

Great if you are using SDK4.1, try the DockerFile approach. @gsardisco 

~Abhinav
(ACSCE, AWS SAA, Azure Admin)