How to change the log location and file name for gradle output using embedded tomcat in cas.war built with 'gradlew run'

35 views
Skip to first unread message

crdaudt

unread,
Jan 6, 2020, 12:31:57 PM1/6/20
to CAS Community
I have built and deployed cas v6.1.1 using gradle and am using systemd to start cas via 'gradlew run'.  CAS functionality and logging appear to be working fine, but the log output for gradle, (which appears to include output normally associated information that is traditionally found in the tomcat catalina.out log file) is being written to ~<cas_user>/.gradle/daemon/<gradle_version>/daemon-<pid>.out.log.  I would prefer to move the log files somewhere within /var/log, preferably without the gradle version number.  I would also prefer to rename the file to a name that is based on the timestamp rather than process id.  How do I configure this?

Also, when placing CAS into production, is running 'gradlew run' in my systemd startup configuration the preferable way to start CAS?

crdaudt

unread,
Jan 9, 2020, 10:12:21 AM1/9/20
to CAS Community
I will restate my questions:
  1. What is the best way to launch cas.war with the embedded tomcat?  The documentation at https://github.com/apereo/cas-overlay-template/tree/6.1 suggests that I use 'gradlew run', which I am currently doing from systemd.  Alternatively, I could launch cas via java directly, such as '$JAVA_HOME/bin/java -server -noverify -Xmx2048M -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -jar .../build/libs/cas.war' .  What is the best practice here?
  2. How do I write the log output where I want it, and with the name that I want?  I am asking here about the gradle log output (I am already able to configure where cas.log and cas_audit.log are written via adjustments to /etc/cas/config/log4j2.xml )?  Currently, the gradle log output is writing to ~<cas_user>/.gradle/daemon/<gradle_version>/daemon-<pid>.out.log .
I look forward to some assistance here.  Thanks!

Jérôme Steve

unread,
Jan 15, 2020, 10:37:33 AM1/15/20
to CAS Community
Hi,

1. In my opinion don't use gradle run in production but launch your war with java directly (Like in the dockerfile cas overlay).
2. response in 1. maybe solve this porblem ?

Jérôme.

crdaudt

unread,
Jan 16, 2020, 10:30:54 AM1/16/20
to CAS Community
Thanks Jérôme.  Indeed, I am finding that launching the cas.war file with java directly seems to be the best approach dealing with logs.  I am not using the dockerfile cas overlay, although perhaps I should be.

crdaudt

unread,
Jan 16, 2020, 10:50:05 AM1/16/20
to CAS Community
As for the log file, by launching the war file directly from the command line with java, i.e., using systemd, the logging information sent to the console is captured by systemd where it can be viewed with journalctl (i.e., systemd logging), but not to  ~<cas_user>/.gradle/daemon/<gradle_version>/daemon-<pid>.out.log .  Once through with debugging, I modified log4j2.xml to limit what is sent to the console.  Specifically, I removed the <AppenderRef ref="casConsole"/> line at the bottom, then changed most of the*.level properties to "warn" rather than "info" or "debug" (exception:  cas.log.level is set to "info").  Log entries appended to the "casFile" and "casAudit" appenders are written only to the files associated with those appenders (by default, cas.log and cas_audit.log), not to systemd logs.

I believe my questions have been answered, but also welcome additional recommendations.
Reply all
Reply to author
Forward
0 new messages