44# This script generates a complete log4j configuration file based on
55# LOG_LEVEL_ environment variables and tells the Java process to use it.
66
7- LOG_CONFIG_FILE=" /generated-log-config.properties"
7+ function log() {
8+ echo ' { "timestamp" : ' " $( date ' +%s' ) " ' ,"severity" : "INFO", "type" : "application","component" : "docker-entrypoint" ,"fullMessage" : "' " $1 " ' "}'
9+ }
810
9- echo " Generating log config at: ${LOG_CONFIG_FILE} "
10- echo " Using Log4j Version: ${LOG4J_VERSION} "
11+ if [ " $LOG4J_VERSION " = " 1" ]; then
12+ FNAME=" log4j.properties"
13+ else
14+ FNAME=" log4j2.properties"
15+ fi
16+
17+
18+ LOG_CONFIG_FILE=" /usr/local/tomcat/webapps/alfresco/WEB-INF/classes/${FNAME} "
19+
20+ log " Generating log config at: ${LOG_CONFIG_FILE} "
21+ log " Using Log4j Version: ${LOG4J_VERSION} "
1122
1223# Start with a clean file
1324touch " ${LOG_CONFIG_FILE} "
@@ -26,7 +37,7 @@ for var in $(env); do
2637 logger_name=$( echo " $var_name " | sed ' s/LOG_LEVEL_//' | sed ' s/_/./g' )
2738
2839 if [ -n " $logger_name " ] && [ -n " $var_value " ]; then
29- echo " Applying log level: ${logger_name} =${var_value} "
40+ log " Applying log level: ${logger_name} =${var_value} "
3041
3142 if [ " $LOG4J_VERSION " = " 1" ]; then
3243 # Log4j 1.x syntax
4758
4859if [ " $LOG4J_VERSION " = " 1" ]; then
4960 # --- Log4j 1.x Config ---
50- echo " Generating Log4j config."
61+ log " Generating Log4j config."
5162 echo " # Auto-generated Log4j 1.x config" >> " ${LOG_CONFIG_FILE} "
5263
5364 # Add a basic console appender
94105# Export new Java options with updated log config
95106export JAVA_OPTS
96107
97- echo " Log configuration complete. JAVA_OPTS updated."
108+ log " Log configuration complete. JAVA_OPTS updated."
0 commit comments