diff --git a/Dockerfile b/Dockerfile index 7ce99b9..5c50891 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,10 @@ RUN apt-get update -qq && \ COPY startup.sh /startup.sh COPY log4j.stdout.replace /log4j.stdout.replace +COPY log4j2.stdout.appenders.replace /log4j2.stdout.appenders.replace +COPY log4j2.stdout.loggers.analytics.replace /log4j2.stdout.loggers.analytics.replace +COPY log4j2.stdout.loggers.root.replace /log4j2.stdout.loggers.root.replace +COPY log4j2.stdout.loggers.vpp.replace /log4j2.stdout.loggers.vpp.replace COPY configuration.sh /configuration.sh CMD ["/startup.sh"] diff --git a/configuration.sh b/configuration.sh index f60b8c7..72f1710 100755 --- a/configuration.sh +++ b/configuration.sh @@ -20,7 +20,13 @@ unpack_root_war() { setup_linux_logging_paths() { #Replace Mac logging paths with linux based paths echo_time "Set logging file paths to use linux file paths" - sed -i s#/Library/JSS/Logs#/usr/local/tomcat/logs# /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/log4j.properties + #Check whether log4j.properties (<= Jamf Pro 10.30.3) or log4j2.xml (>= Jamf Pro 10.31.0) exists + FILE=/usr/local/tomcat/webapps/ROOT/WEB-INF/classes/log4j.properties + if test -f "$FILE"; then + sed -i s#/Library/JSS/Logs#/usr/local/tomcat/logs# /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/log4j.properties + else + sed -i s#/Library/JSS/Logs#/usr/local/tomcat/logs# /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/log4j2.xml + fi } setup_stdout_logging() { @@ -28,12 +34,32 @@ setup_stdout_logging() { if [[ $STDOUT_LOGGING == "true" ]]; then #Add stdout output for Jamf specific log files while maintaining logging to the files echo_time "STDOUT_LOGGING is true, add stdout logging for all logfiles" - if grep -Fxq "log4j.rootLogger=INFO,JAMF,stdout" /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/log4j.properties; then - echo_time "stdout logging appears to be present in log4j.properties file, skipping" + #Check whether log4j.properties (<= Jamf Pro 10.30.3) or log4j2.xml (>= Jamf Pro 10.31.0) exists + FILE=/usr/local/tomcat/webapps/ROOT/WEB-INF/classes/log4j.properties + if test -f "$FILE"; then + echo_time "Found log4j.properties, enable logging to stdout" + if grep -Fxq "log4j.rootLogger=INFO,JAMF,stdout" /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/log4j.properties; then + echo_time "stdout logging appears to be present in log4j.properties file, skipping" + else + echo_time "Add stdout logging to log4j.properties file" + sed -e '/log4j.rootLogger/ {r /log4j.stdout.replace + d}' -i /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/log4j.properties + fi else - echo_time "Add stdout logging to log4j.properties file" - sed -e '/log4j.rootLogger/ {r /log4j.stdout.replace - d}' -i /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/log4j.properties + echo_time "Found log4j2.xml, enable logging to stdout" + if grep -Fxq ' ' /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/log4j2.xml; then + echo_time "stdout logging appears to be present in log4j2.xml file, skipping" + else + echo_time "Add stdout logging to log4j2.xml file" + sed -e '// {r /log4j2.stdout.appenders.replace + d}' -i /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/log4j2.xml + sed -e '// {r /log4j2.stdout.loggers.root.replace + d}' -i /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/log4j2.xml + sed -e '// {r /log4j2.stdout.loggers.analytics.replace + d}' -i /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/log4j2.xml + sed -e '// {r /log4j2.stdout.loggers.vpp.replace + d}' -i /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/log4j2.xml + fi fi fi } diff --git a/log4j2.stdout.appenders.replace b/log4j2.stdout.appenders.replace new file mode 100644 index 0000000..98201bd --- /dev/null +++ b/log4j2.stdout.appenders.replace @@ -0,0 +1,5 @@ + + + + + diff --git a/log4j2.stdout.loggers.analytics.replace b/log4j2.stdout.loggers.analytics.replace new file mode 100644 index 0000000..dc6710a --- /dev/null +++ b/log4j2.stdout.loggers.analytics.replace @@ -0,0 +1,2 @@ + + diff --git a/log4j2.stdout.loggers.root.replace b/log4j2.stdout.loggers.root.replace new file mode 100644 index 0000000..e821773 --- /dev/null +++ b/log4j2.stdout.loggers.root.replace @@ -0,0 +1,2 @@ + + diff --git a/log4j2.stdout.loggers.vpp.replace b/log4j2.stdout.loggers.vpp.replace new file mode 100644 index 0000000..a6b4055 --- /dev/null +++ b/log4j2.stdout.loggers.vpp.replace @@ -0,0 +1,2 @@ + +