wood burning stoves 2.0*
The moose likes JSF and the fly likes enable jsf logging Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "enable jsf logging" Watch "enable jsf logging" New topic
Author

enable jsf logging

Christophe Basse
Greenhorn

Joined: Jun 07, 2006
Posts: 10
Hi,

I'm trying to debug my jsf application running with weblogic 9 but I can't find out how to do it.

I found that the jsf spec is doing this :
if(log.isTraceEnabled()) ....

So my question is : How to enable the Trace (for example).

I searched for hours and only found some log4j stuff while I think it should be not so complex to enable this logging level.

Thanks in advance
Christophe
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16019
    
  20

There are 3 popular log/trace facilities commonly used in Java: log4j, apache commons logging, and the JDK logger. Log4j and apache logging can intercept JDK logging (and, it think each other) so a mixed logging system is not only possible, but often done. For example, I think Tomcat's presently using log4j, but deployed webapps don't have to.

You do not normally enable tracing - or any of the other logging levels for that matter internal to the application. At best, it's extra logic. At worst, something blows up in the middle of the night and you have to recompile the app to see what's wrong. So instead you use the logging config files.

The major Java loggers all allow you to fine-tune logging at the package level. This means not only that you can keep yourself from being buried alive in stuff from uninteresting parts of your own app, but that if you need to trace org.apache.commons.digester stuff, you won't automatically have to endure noise from org.apache.commons.collections.

So the simplest way to trace is :



The logging methods were designed for minimal overhead. You only need to check loglevels if you intend to format your log message using expensive operations that won't be used if the log isn't written. Use it only to bypass the expensive logic and never put application logic in a loglevel test! Otherwise everytime you change the logging environment, the program will go bonkers.


Customer surveys are for companies who didn't pay proper attention to begin with.
Christophe Basse
Greenhorn

Joined: Jun 07, 2006
Posts: 10
Thanks but my problem at the moment is that when I click on a commandLink, no action is done (but I'm correctly redirected to the same page as configured in faces-config.xml).

I have identified that this is happening when I put a SelectOneMenu object (because it works when I remove it).

Problem is that I don't have any idea where is this going wrong ... So I wanted to log what's going on in the servlet. And I saw that in FacesServlet spec they use the isTraceEnabled method. That's what I wanted to put logging on only on jsf core methods and not on mine.

So is it possible ?
naveen gupta
Ranch Hand

Joined: Apr 12, 2006
Posts: 129
Christophe
i think, i know exactly where you are going wrong. just 1 week ago i was in your position and took 1 week to find after googling and lots of posting on the forums. so here it is

in JSF, for input text fields, other than strings we need to do conversion, like for example, if your are using Date field, then you need to do conversion . Check out Date field conversion for JSF in google. If you don't do conversion JSF doesn't complain and there will be no errors in the log. But you actions doesn't work like h:commandButton. Nope, they don't work

I don't know what all fields you are using in your JSF, you can put a simple text field of String type and test it, it works.

if you want log, then you need to put validation errors for the fields. Even if you really don't want to validate the fields

let me know if it works. Feels great to solve it ( if i did )
Richard Green
Ranch Hand

Joined: Aug 25, 2005
Posts: 536
I use eclipse as my Java IDE. Using eclipse, I can debug both Tomcat and JBoss (Application Server). Stepping through the code and identifying the problem is now much easier.

Also you might be interested in this
[ July 27, 2006: Message edited by: Lynette Dawson ]

MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)
Christophe Basse
Greenhorn

Joined: Jun 07, 2006
Posts: 10
I also use eclipse but have no idea about how to debug ....

ps: your link is not working
Richard Green
Ranch Hand

Joined: Aug 25, 2005
Posts: 536
I have corrected the link.

See http://tomcat.apache.org/faq/development.html#rd for remote debugging Tomcat through Eclipse.

To debug JBoss:

Configuring Eclipse for remote debugging

Step 1: Modify the JBoss run.bat as follows:

Uncomment the following line

set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y %JAVA_OPTS%

Step 2: Eclipse > Run > Debug > Remote Java Application > New

Set the connection Properties as follows:

Host: localhost
Port: 8787

Now goto the "Source" tab and select your projects and press "Debug"

Set a breakpoint in your Java source code and switch to Debug perspective

Thats it
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: enable jsf logging