Re: custom log formatter for hpi:run ?
Hi Jerome, thanks for your suggestions. They forced me to think deeper. After fiddling with maven-hpi-plugin 1.92-SNAPSHOT I found the jar: I had to stick my log formatter into maven/boot/plexus-classworlds-2.4.jar. Weird, but now it does what I want. I captured my findings on this Wiki page: https://wiki.jenkins-ci.org/display/JENKINS/custom+log+formatter+for+hpi-run Regards, -Max On 12/01/2012 08:29 AM, Jerome Lacoste wrote: On Thursday, November 29, 2012 7:30:13 PM UTC+1, Max Spring wrote: I am able to make my logging.properties active. That's not the problem. I'm unable get my custom formatter being used! This seems to be more of a class loader issue. Using MAVEN_OPTS works equally to using -D on the command line. Are you using the maven2 jenkins plugin ? Doesn't that one bootstrap maven into it's own classloader ? Your class would maybe not be available there. Have you tried 1- adding your class in a jar under your MAVEN_HOME/lib/ext run mvn in the command line using your option and overriden logger 2- run again this time from jenkins It might also work by placing the class into the maven2 plugin instead. I am not sure how the classloading is implemented in the plugin. Maybe olivier lamy can answer that. Jerome -Max On 11/28/2012 03:43 PM, Kohsuke Kawaguchi wrote: On 11/27/2012 06:03 PM, Max Spring wrote: I'm struggling getting a custom formatter to play under hpi:run. I can pass my own logging.properties on the command line: mvn hpi:run -Djava.util.logging.config.file=my-logging.properties but my formatter doesn't get used. I haven't read the code, but I suspect java.util.logging is using the system property value before Maven gets to process its command line arguments and makes the corresponding System.setProperty(...) call. Try setting it via MAVEN_OPTS env variable. I can switch on/off the built-in XMLFormatter. This proves that my-logging.properties are active: java.util.logging.ConsoleHandler.formatter = org.example.MyFormatter # java.util.logging.ConsoleHandler.formatter = java.util.logging.XMLFormatter I suspect this is similar to this problem: http://jenkins.361315.n4.nabble.com/how-to-set-logging-properties-td3479817.html http://jenkins.361315.n4.nabble.com/how-to-set-logging-properties-td3479817.html But I can't figure out how to make my formatter class visible. Adding it to the Jenkins war doesn't do the trick here. Has anyone solved this? Thanks! -Max
Re: custom log formatter for hpi:run ?
On Thursday, November 29, 2012 7:30:13 PM UTC+1, Max Spring wrote: I am able to make my logging.properties active. That's not the problem. I'm unable get my custom formatter being used! This seems to be more of a class loader issue. Using MAVEN_OPTS works equally to using -D on the command line. Are you using the maven2 jenkins plugin ? Doesn't that one bootstrap maven into it's own classloader ? Your class would maybe not be available there. Have you tried 1- adding your class in a jar under your MAVEN_HOME/lib/ext run mvn in the command line using your option and overriden logger 2- run again this time from jenkins It might also work by placing the class into the maven2 plugin instead. I am not sure how the classloading is implemented in the plugin. Maybe olivier lamy can answer that. Jerome -Max On 11/28/2012 03:43 PM, Kohsuke Kawaguchi wrote: On 11/27/2012 06:03 PM, Max Spring wrote: I'm struggling getting a custom formatter to play under hpi:run. I can pass my own logging.properties on the command line: mvn hpi:run -Djava.util.logging.config.file=my-logging.properties but my formatter doesn't get used. I haven't read the code, but I suspect java.util.logging is using the system property value before Maven gets to process its command line arguments and makes the corresponding System.setProperty(...) call. Try setting it via MAVEN_OPTS env variable. I can switch on/off the built-in XMLFormatter. This proves that my-logging.properties are active: java.util.logging.ConsoleHandler.formatter = org.example.MyFormatter # java.util.logging.ConsoleHandler.formatter = java.util.logging.XMLFormatter I suspect this is similar to this problem: http://jenkins.361315.n4.nabble.com/how-to-set-logging-properties-td3479817.html But I can't figure out how to make my formatter class visible. Adding it to the Jenkins war doesn't do the trick here. Has anyone solved this? Thanks! -Max
Re: custom log formatter for hpi:run ?
On 11/27/2012 06:03 PM, Max Spring wrote: I'm struggling getting a custom formatter to play under hpi:run. I can pass my own logging.properties on the command line: mvn hpi:run -Djava.util.logging.config.file=my-logging.properties but my formatter doesn't get used. I haven't read the code, but I suspect java.util.logging is using the system property value before Maven gets to process its command line arguments and makes the corresponding System.setProperty(...) call. Try setting it via MAVEN_OPTS env variable. I can switch on/off the built-in XMLFormatter. This proves that my-logging.properties are active: java.util.logging.ConsoleHandler.formatter = org.example.MyFormatter # java.util.logging.ConsoleHandler.formatter = java.util.logging.XMLFormatter I suspect this is similar to this problem: http://jenkins.361315.n4.nabble.com/how-to-set-logging-properties-td3479817.html But I can't figure out how to make my formatter class visible. Adding it to the Jenkins war doesn't do the trick here. Has anyone solved this? Thanks! -Max -- Kohsuke Kawaguchi | CloudBees, Inc. | http://cloudbees.com/ Try Nectar, our professional version of Jenkins
custom log formatter for hpi:run ?
I'm struggling getting a custom formatter to play under hpi:run. I can pass my own logging.properties on the command line: mvn hpi:run -Djava.util.logging.config.file=my-logging.properties but my formatter doesn't get used. I can switch on/off the built-in XMLFormatter. This proves that my-logging.properties are active: java.util.logging.ConsoleHandler.formatter = org.example.MyFormatter # java.util.logging.ConsoleHandler.formatter = java.util.logging.XMLFormatter I suspect this is similar to this problem: http://jenkins.361315.n4.nabble.com/how-to-set-logging-properties-td3479817.html But I can't figure out how to make my formatter class visible. Adding it to the Jenkins war doesn't do the trick here. Has anyone solved this? Thanks! -Max