Just wanted to post my solution to my Log4J problem, which I posted as a
response to someone else's similar problem a few weeks ago. Apologies
if this is a widely known issue, but in casually reading this list and
checking Tap 4 documentation, I haven't seen this mentioned specifically.
After some research, I saw that the cause of the problem was that
Tapestry 4 instantiates its concrete page objects differently than Tap 3
did, which causes problems if you have created your logger using
Logger.getLogger(this.getClass()) ;
In Tap 4, if you try to check the package using a call like
this.getClass().getPackage().getName();
you'll actually get a NullPointerException, because getPackage() doesn't
return a package. Now I am not really familiar with Log4J's internals,
but it apparently uses this call or one like it to try to determine
whether or not to log a message. In Tap3, the package of the
instantiated class was something (I didn't go back and check this),
probably the package in the abstract page class, that allowed Log4J to
determine that it did need to log messages created using that class's
logger.
The solution, if you have created your Logger using Logger.getLogger(),
is just to call
Logger logger = Logger.getLogger(this.getClass().getSuperclass());
which will instantiate your logger with your abstract class, not
Tapestry's concrete class, and allow Log4J to work correctly.
Matt
Matthew Larson wrote:
I am having the exact same problem. I upgraded from a Tap 3
environment under Tomcat where I used log4j, and all of a sudden some
of my logging messages fail to appear--but only if the logging takes
place within a Tapestry page or component .java file. My DAOs and
such, if they contain logging messages, work fine. I have checked and
rechecked my log4j.properties, which I did not change from my previous
Tap 3 project. The settings are correct. Obviously there's something
I don't understand about Tapestry's instantiation of my abstract page
and component classes, something that is throwing log4j off. I was
planning to investigate the problem more thoroughly, but if others are
having it and someone knows the answer already, that would save me and
Lennart some time...
Thanks in advance for any help.
Matt
Lennart Benoot wrote:
Hi all,
Yesterday I deployed my first tapestry 4 application. I noticed that
there there is hardly any logging in the log file. The only logging I
see is :
Feb 21, 2006 8:00:57 PM org.apache.tapestry.ApplicationServlet init
INFO: Initialized application servlet
'org.apache.catalina.INVOKER.hadron.vocawb.ApplicationServlet': 2,413
millis to create HiveMind Registry, 5,490 millis overall.
How can I have more logging?
Thanks,
Lennart
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]