demetrio812

26 August 2007

Configuring JBoss AS logging level using Log4j

Loggin during the development phase is really important, but when you go in production it can be a problem: in my case my application add about 6MB of log for a single request and this can be a real problem if you have a lot of users. More, writing so much stuff would decrease performance of the application.

If you use JBoss Application Server (that use log4j) it's simple to configure it to do not write a lot of debug stuff for the classes of my applications (that generally are written using JSF + Ajax4Jsf + Richfaces + Seam technologies).

To do that, modify the jboss-log4j.xml file that you find in /< jboss_home_dir >/server/< your_conf >/conf/ and add this code inside the log4j:configuration section:


< category name="org.jboss">
< priority value="INFO"/>
< /category>

< category name="javax.faces">
< priority value="INFO"/>
< /category>

< category name="org.ajax4jsf">
< priority value="INFO"/>
< /category>

< category name="org.hibernate">
< priority value="INFO"/>
< /category>


As you can see it's simple to adapt for other libraries you are using.

Other than INFO you can use other logging levels, they are ordered in that order:

DEBUG < INFO < WARN < ERROR < FATAL.

So using the INFO level log4j will skip DEBUG logs but it will write WARN, ERROR and FATAL logs, using ERROR level it will only write ERROR and FATAL logs an so on.

Demetrio Filocamo

Labels: , , ,

25 August 2007

Install Tomahawk in a seam-gen generated project

Hi,
installing Tomahawk in a Facelets + Seam + JSF project (generated by seam-gen) is really simple:
  1. Add library tomahawk*.jar in lib directory (download from http://myfaces.apache.org/tomahawk/)

  2. Also add those dependencies:
  3. Inside directory resources/WEB-INF create a file named tomahawk.taglib.xml and fill in with contents that you find in the example section to this address: http://wiki.apache.org/myfaces/Use_Facelets_with_Tomahawk
    or you can download it from here.

  4. in web.xml add:

    <context-param>
    <param-name>facelets.LIBRARIES</param-name>
    <param-value>/WEB-INF/tomahawk.taglib.xml</param-value>
    </context-param>
    <!-- Tomahawk -->
    <filter>
    <filter-name>MyFacesExtensionsFilter</filter-name>
    <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
    <init-param>
    <param-name>maxFileSize</param-name>
    <param-value>20m</param-value>
    </init-param>
    </filter>

    <!-- extension mapping for adding <script/>, <link/>, and other resource tags to JSF-pages -->
    <filter-mapping>
    <filter-name>MyFacesExtensionsFilter</filter-name>
    <!-- servlet-name must match the name of your javax.faces.webapp.FacesServlet entry -->
    <servlet-name>Faces Servlet</servlet-name>
    </filter-mapping>

    <!-- extension mapping for serving page-independent resources (javascript, stylesheets, images, etc.) -->
    <filter-mapping>
    <filter-name>MyFacesExtensionsFilter</filter-name>
    <url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
    </filter-mapping>

  5. In build.xml, in < todir="${war.dir}/WEB-INF/lib"> section , inside the < dir="${lib.dir}"> tag, add:

    <name="tomahawk*.jar">
    <name="commons-codec*.jar">
    <name="commons-el*.jar">
    <name="commons-fileupload*.jar">
    <name="commons-lang*.jar">
    <name="commons-logging*.jar">
    <name="commons-validator*.jar">
    <name="commons-validator*.js">
    <name="jakarta-oro*.jar">


  6. To use the library in xhtml pages:

    xmlns:t="http://myfaces.apache.org/tomahawk"
Btw THERE IS A PROBLEM: I just found that after adding Tomahawk library the Seam file upload doesn't work, I will tell you more in another post...

Demetrio Filocamo

P.S.: sorry for bad code posting (I putted a space to make tag visibles), I have to find the time to configure an appropriate css style for code showing.

Labels: , , ,