header
header
Main Menu
Home
Eviware Store
Downloads
Products
News
Forum
Eviware Blog
Search
FAQs
Customer Area
Support
Documentation
Tutorials
CookBook
Downloads
Forum
Login Form
Welcome, Guest. Please login or register.
December 05, 2008, 12:25:37 am
Username: Password:
Login with username, password and session length

Forgot your password?
 
Log4j and extending the HtmlLayout layout class
Welcome, Guest. Please login or register.
December 05, 2008, 12:25:37 am
Home Help Search Login Register
News: The Forums are up! Welcome to eviware.

+  Eviware Forum
|-+  soapUI
| |-+  soapUI
| | |-+  Log4j and extending the HtmlLayout layout class
« previous next »
Pages: [1] Print
Author Topic: Log4j and extending the HtmlLayout layout class  (Read 747 times)
Joey Seekata
Newbie
*
Posts: 4


« on: September 20, 2007, 02:40:07 pm »

I think this is really about hooking in java code in general, but my specific need is to extend HTMLLayout (org.apache.log4j.HTMLLayout).  In the version of log4j that comes with SOAPui, the output from HTMLLayout is fixed (HTMLLayout does not derive from PatternLayout and therefore does not accept an ConversionPattern).

If I were to extend HTMLLayout in java, can I hook that code into SOAPui?  For example, I currently have this in soapui-log4j.xml:

  <appender name="testResults" class="org.apache.log4j.FileAppender">
     <param name="File" value="testResults.html"/>
     <layout class="org.apache.log4j.HTMLLayout">
      </layout>
   </appender>

What I would like to do is (for example):

  <appender name="testResults" class="org.apache.log4j.FileAppender">
     <param name="File" value="testResults.html"/>
     <layout class="com.company.project.MyHtmlLayout">
      </layout>
   </appender>

Where would I put the jar file that contains com.company.project.MyHtmlLayout such that SOAPui will load it up at startup?

Thanks for your attention to this matter.

Joey
Logged
omatzura
Administrator
Hero Member
*****
Posts: 1,506


« Reply #1 on: September 20, 2007, 10:40:35 pm »

Hi Joey,

normally you would be able to drop the jar-file into the <soapui>\bin\ext folder, but since the log4j configuration is read before this folder is processed, you will need to manually add your jar to the classpath in soapui.bat.. unless log4j doesn't actually instantiate your layout until after the bin\ext folder has been processed (which is just after the log4j.xml file has been read), in which case you should be able to just put your jar in the bin\ext folder..

Hope this helps!

regards!

/Ole
eviware.com
Logged
Joey Seekata
Newbie
*
Posts: 4


« Reply #2 on: October 11, 2007, 06:49:00 pm »

Omatzura,

Thanks so much.  Turns out log4j is processed first so the soapui-pro.bat file needed to be modified. 

Next task, resetting the log file when a test case is run.  log4j's FileAppender has a property "Append" and it is set to false.  So when SoapUI-Pro starts up, the old log file is cleared (emptied of data).  That is great, but what I am being asked to do requires that same emptying for each test case run.  Any thoughts?  I have, of course, poured over the log4j documents and do not see anything that looks promising, so I am asking here.

Thanks again,

Joey
Logged
omatzura
Administrator
Hero Member
*****
Posts: 1,506


« Reply #3 on: October 11, 2007, 07:16:55 pm »

Hi Joey,

maybe you can create a groovy-script first in your testcase that gets the loggers' FileAppender and calls its activateOptions method? ie

Logger.getLogger(..).getAppender( .. ).activateOptions()

which should reset the log (if I understand the javadocs correctly)!?

Hope this helps!

regards,

/Ole
eviware.com
Logged
Joey Seekata
Newbie
*
Posts: 4


« Reply #4 on: October 11, 2007, 08:49:39 pm »

Omatzura,

I don't know how you got that from the javadocs, but it was brilliant.  I used:

Logger.getRootLogger().getAppender("testResults").activateOptions();

and sure enough, it closed and reopened it.  With append set to false, it reopened it "clean".

I could not figure out what name to put into the Logger.getLogger call, so I used getRootLogger instead.

Who said there are no pointers in java?  You pointed me in the right direction with some java code.

But still, how did you get that behavior from the javadocs?  Some kind of secret decoder ring or what?

Thanks so much!

Joey
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
header header
header
header