Hi all,
I'm going crazy over a trivial configuration of log4j2 on alfresco 7.4+
Have any of you ever had problems declaring new custom loggers for new module packages using the standard Docker Deployment with SDK 4.8 for ACS?
I followed this guide https://docs.alfresco.com/content-services/latest/upgrade/log4j2-migrate/ but it seems that it doesn't take my custom configuration in any case. I tried editing custom-log4j2.properties defined under src/main/resources/alfresco/module/mymodule/ and also dev-log4j2.properties defined in the platform docker project.
My custom logger definitions follow exactly the structure of the guide I linked before from the alfresco documentation. Thanks in advance
Solved! Go to Solution.
Hi all,
after lots of tests we found out the solution, following the [MNT-24306] Added fix for log4j2 config issue.
In order to get the logs inside the docker environment created by the run.sh build_start command you need to:
1) Edit the following 2 files:
1.1) Dockerfile inside the <my-project>-platform-docker module
FROM ${docker.acs.image}:${alfresco.platform.version} ARG TOMCAT_DIR=/usr/local/tomcat ARG USERNAME=${alfresco.platform.docker.user} 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 COPY alfresco-global.properties $TOMCAT_DIR/shared/classes/alfresco-global.properties COPY dev-log4j2.properties $TOMCAT_DIR/shared/classes/alfresco/extension/dev-log4j2.properties 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/ # Move the log file RUN sed -i -e "s_appender.rolling.fileName\=alfresco.log_appender.rolling.fileName\=${TOMCAT_DIR}/logs\/alfresco.log_" \ ${TOMCAT_DIR}/shared/classes/alfresco/extension/dev-log4j2.properties && \ sed -i -e "s_appender.rolling.filePattern=alfresco.log.%d{yyyy-MM-dd}_appender.rolling.filePattern\=${TOMCAT_DIR}/logs\/alfresco.log.%d{yyyy-MM-dd}_" \ ${TOMCAT_DIR}/shared/classes/alfresco/extension/dev-log4j2.properties USER ${USERNAME}
1.2) dev-log4j2.properties inside the <my-project>-platform-docker module
rootLogger.level=error rootLogger.appenderRef.stdout.ref=ConsoleAppender rootLogger.appenderRef.rolling.ref=RollingAppender .....
.....
# Authorization logger.alfresco-enterprise-repo-authorization-AuthorizationService.name=org.alfresco.enterprise.repo.authorization.AuthorizationService logger.alfresco-enterprise-repo-authorization-AuthorizationService.level=info logger.alfresco-enterprise-repo-authorization-AuthorizationsConsistencyMonitor.name=org.alfresco.enterprise.repo.authorization.AuthorizationsConsistencyMonitor logger.alfresco-enterprise-repo-authorization-AuthorizationsConsistencyMonitor.level=warn
From line 1 to line 402 of this link:
2) Add your package configuration at the end of the dev-log4j2.properties
import org.slf4j.Logger; import org.slf4j.LoggerFactory;CARE: do not use org.apache.commons.logging as for us it didn't work (even if is the method used inside the DemoComponent of the SDK)
//inside your class private static final Logger logger = LoggerFactory.getLogger(MyClass.class);
//inside your method logger.debug("Test debug logging. Congratulation your JAR Module is working"); logger.info("This is only for information purposes. Better remove me from the log in Production");
It looks like there is a problem with the SDK.
This PR seems to fix the issue: https://github.com/Alfresco/alfresco-sdk/pull/664
Hi all,
after lots of tests we found out the solution, following the [MNT-24306] Added fix for log4j2 config issue.
In order to get the logs inside the docker environment created by the run.sh build_start command you need to:
1) Edit the following 2 files:
1.1) Dockerfile inside the <my-project>-platform-docker module
FROM ${docker.acs.image}:${alfresco.platform.version} ARG TOMCAT_DIR=/usr/local/tomcat ARG USERNAME=${alfresco.platform.docker.user} 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 COPY alfresco-global.properties $TOMCAT_DIR/shared/classes/alfresco-global.properties COPY dev-log4j2.properties $TOMCAT_DIR/shared/classes/alfresco/extension/dev-log4j2.properties 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/ # Move the log file RUN sed -i -e "s_appender.rolling.fileName\=alfresco.log_appender.rolling.fileName\=${TOMCAT_DIR}/logs\/alfresco.log_" \ ${TOMCAT_DIR}/shared/classes/alfresco/extension/dev-log4j2.properties && \ sed -i -e "s_appender.rolling.filePattern=alfresco.log.%d{yyyy-MM-dd}_appender.rolling.filePattern\=${TOMCAT_DIR}/logs\/alfresco.log.%d{yyyy-MM-dd}_" \ ${TOMCAT_DIR}/shared/classes/alfresco/extension/dev-log4j2.properties USER ${USERNAME}
1.2) dev-log4j2.properties inside the <my-project>-platform-docker module
rootLogger.level=error rootLogger.appenderRef.stdout.ref=ConsoleAppender rootLogger.appenderRef.rolling.ref=RollingAppender .....
.....
# Authorization logger.alfresco-enterprise-repo-authorization-AuthorizationService.name=org.alfresco.enterprise.repo.authorization.AuthorizationService logger.alfresco-enterprise-repo-authorization-AuthorizationService.level=info logger.alfresco-enterprise-repo-authorization-AuthorizationsConsistencyMonitor.name=org.alfresco.enterprise.repo.authorization.AuthorizationsConsistencyMonitor logger.alfresco-enterprise-repo-authorization-AuthorizationsConsistencyMonitor.level=warn
From line 1 to line 402 of this link:
2) Add your package configuration at the end of the dev-log4j2.properties
import org.slf4j.Logger; import org.slf4j.LoggerFactory;CARE: do not use org.apache.commons.logging as for us it didn't work (even if is the method used inside the DemoComponent of the SDK)
//inside your class private static final Logger logger = LoggerFactory.getLogger(MyClass.class);
//inside your method logger.debug("Test debug logging. Congratulation your JAR Module is working"); logger.info("This is only for information purposes. Better remove me from the log in Production");
great!
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.