Thanks a lot Chris for implementing this feature which opens up new potentials
for automation (e.g. automated compatibility testing across java/tomcat
major branch latest versions in a ci pipeline, and always using the latest buildpack version), I love it!
Some teams might find it useful
to define some of these variables in a "staging environment variable
group" when it makes sense to share them among apps, and they don't want
to fork the buildpack. Wondering whether it could make sense to mention
it into
https://github.com/cloudfoundry/java-buildpack#configuration-and-extension.
I tried defining the key into a manifest but it seems the cli rejected it, unless I mistyped it ? Should I submit a cli issue ?
$ cat pivotal-spring-travel-master.yml
---
applications:
- name: spring-travel
[...]
env:
- JBP_CONFIG_TOMCAT: '[ access_logging_support: { access_logging: enabled } ]'
$ cf push -f pivotal-spring-travel-master.yml --no-start -b https://github.com/cloudfoundry/java-buildpack.git
FAILED
Error reading manifest file:
Expected env to be a set of key => value, but it was a [map[JBP_CONFIG_TOMCAT:[ access_logging_support: { access_logging: enabled } ]]].
$ cf --version
C:\Program Files (x86)\CloudFoundry\cf.exe version 6.10.0-b78bf10-2015-02-11T22:26:25+00:00
Assigning the same env with "cf set-env" works fine.
I
tried enabling the tomcat access logging
with it. This seems to indeed trigger the access logging in the
buildpack, but I can't see the logs coming out in cf logs. I'm suspecting
this is unrelated to buildpack config (maybe a regression w.r.t. tomcat
version ?). Full details follow (should we continue in another thread or a dedicated java-buildpack issue?).
Thanks again,
Guillaume.
$ cf push -f pivotal-spring-travel-master.yml --no-start -b https://github.com/cloudfoundry/java-buildpack.git
$ cf set-env spring-travel JBP_LOG_LEVEL DEBUG
$ cf set-env spring-travel JBP_CONFIG_TOMCAT '[ access_logging_support: { access_logging: enabled } ]'
Access logs don't output:
$ cf logs spring-travel
Connected, tailing logs for app spring-travel in org bercheg-org / space development as bercheg...
2015-03-26T12:52:08.52+0100 [App/0] OUT DEBUG: org.springframework.webflow.mvc.servlet.FlowHandlerMapping - No flow mapping found for request with URI '/'
2015-03-26T12:52:08.54+0100 [RTR/1] OUT spring-travel-nonoperatic-plagioclastic.cfapps.io - [26/03/2015:11:52:08 +0000] "GET / HTTP/1.1" 200 3662 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:36.0) Gecko/20100101 Firefox/36.0" 10.10.2.122:45631 x_forwarded_for:"193.252.157.50" vcap_request_id:fa987115-cebf-4242-5450-24785692abe0 response_time:0.011854906 app_id:f6f01940-217e-4164-b134-75430b45619f
2015-03-26T12:52:08.80+0100 [App/0] OUT DEBUG: org.springframework.webflow.mvc.servlet.FlowHandlerMapping - No flow mapping found for request with URI '/resources/javascript/spring/Spring-Dojo.js'
2015-03-26T12:52:08.82+0100 [RTR/1] OUT spring-travel-nonoperatic-plagioclastic.cfapps.io - [26/03/2015:11:52:08 +0000] "GET /resources/javascript/spring/Spring-Dojo.js HTTP/1.1" 304 0 "http://spring-travel-nonoperatic-plagioclastic.cfapps.io/" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:36.0) Gecko/20100101 Firefox/36.0" 10.10.2.122:45631 x_forwarded_for:"193.252.157.50" vcap_request_id:5a961d61-c140-4db8-66a
I indeed see the config modification triggered
[ConfigurationUtils] DEBUG Configuration from /tmp/buildpacks/java-buildpack/config/tomcat.yml: {"tomcat"=>{"version"=>"8.0.+", "repository_root"=>"{default.repository.root}/tomcat"}, "lifecycle_support"=>{"version"=>"2.+", "repository_root"=>"{default.repository.root}/tomcat-lifecycle-support"}, "logging_support"=>{"version"=>"2.+", "repository_root"=>"{default.repository.root}/tomcat-logging-support"}, "access_logging_support"=>{"version"=>"2.+", "repository_root"=>"{default.repository.root}/tomcat-access-logging-support", "access_logging"=>"disabled"}, "redis_store"=>{"version"=>"1.+", "repository_root"=>"{default.repository.root}/redis-store", "database"=>0, "timeout"=>2000, "connection_pool_size"=>2}, "gemfire_store"=>{"gemfire"=>{"version"=>"8.0.+", "repository_root"=>"{default.repository.root}/gem-fire"}, "gemfire_modules"=>{"version"=>"8.0.+", "repository_root"=>"{default.repository.root}/gem-fire-modules"}, "gemfire_modules_tomcat7"=>{"version"=>"8.0.+", "repository_root"=>"{default.repository.root}/gem-fire-modules-tomcat7"}, "gemfire_security"=>{"version"=>"8.0.+", "repository_root"=>"{default.repository.root}/gem-fire-security"}, "gemfire_logging"=>{"version"=>"1.5.8", "repository_root"=>"{default.repository.root}/slf4j-jdk14"}, "gemfire_logging_api"=>{"version"=>"1.5.8", "repository_root"=>"{default.repository.root}/slf4j-api"}}}
[ConfigurationUtils] DEBUG Configuration from /tmp/buildpacks/java-buildpack/config/tomcat.yml modified with: [ access_logging_support: { access_logging: enabled, version: "2.+", repository_root: "{default.repository.root}/tomcat-access-logging-support" } ]
and the logging support being downloaded and enabled in JVM properties
App spring-travel was started using this command `JAVA_HOME=$PWD/.java-buildpack/open_jdk_jre JAVA_OPTS="-Djava.io.tmpdir=$TMPDIR -XX:OnOutOfMemoryError=$PWD/.java-buildpack/open_jdk_jre/bin/killjava.sh -Xmx768M -Xms768M -XX:MaxMetaspaceSize=104857K -XX:MetaspaceSize=104857K -Xss1M -Daccess.logging.enabled=true -Dhttp.port=$PORT" $PWD/.java-buildpack/tomcat/bin/catalina.sh run`
$ cf files spring-travel app/.java-buildpack/tomcat/lib | grep logging
tomcat_access_logging_support-2.4.0_RELEASE.jar 3.5K
The access valve seems enabled in tomcat:
$ cf files spring-travel app/.java-buildpack/tomcat/conf/server.xml
Getting files for app spring-travel in org bercheg-org / space development as bercheg@gmail.com...
OK
<?xml version='1.0' encoding='utf-8'?>
<Server port='-1'>
<Service name='Catalina'>
<Connector port='${http.port}' bindOnInit="false"/>
<Engine defaultHost='localhost' name='Catalina'>
<Valve className="org.apache.catalina.valves.RemoteIpValve" protocolHeader="x-forwarded-proto"/>
<Valve className="com.gopivotal.cloudfoundry.tomcat.logging.access.CloudFoundryAccessLoggingValve"
pattern='[ACCESS] %{org.apache.catalina.AccessLog.RemoteAddr}r %l %t %D %F %B %S vcap_request_id:%{X-Vcap-Request-Id}i'
enabled="${access.logging.enabled}"/>
<Host name='localhost'>
<Listener className="com.gopivotal.cloudfoundry.tomcat.lifecycle.ApplicationStartupFailureDetectingLifecycleListener"/>
</Host>
</Engine>
</Service>
</Server>