File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HttpSessionListener : Where can i see this output ?

 
Rahul Sudip Bose
Ranch Hand
Posts: 637
Eclipse IDE Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I saw some println() statements below. They wont be in the response. So where can i see them ?
Also, how do i see the number of total-active-sessions ? how do i display it in my response ?

The code:



here is the link where i got it : http://www.mkyong.com/servlet/a-simple-httpsessionlistener-example-active-sessions-counter/
 
rinku jain
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use out.println("");

instead of system.out.println();//this out put will be shown on server console
 
Ravishanker kumar
Ranch Hand
Posts: 53
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Those would be appear on server console.
 
Rahul Sudip Bose
Ranch Hand
Posts: 637
Eclipse IDE Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ravishanker kumar wrote:Those would be appear on server console.


How to see the server console ? (i am using tomcat 6)
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17646
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, println isn't something we encourage. There's no telling where it can end up, since it's up to the server to decide. It's better to use one of the loggers such as log4j or java.util.logging interface (a/k/a "JULI").

The console for Tomcat is usually the logs/catalina.out file. Except when it isn't. The catalina.out file is normally directed there, but in a few specialized Tomcat configurations, it may be directed somewhere else. It's actually just the JVM's stdout/stderr.
 
Rahul Sudip Bose
Ranch Hand
Posts: 637
Eclipse IDE Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:
It's better to use one of the loggers such as log4j or java.util.logging interface (a/k/a "JULI").


I am new and i was wondering if log4J can take more than a day to learn for basic purposes ? java.util.logging - any suggestions for how i can learn to use this (links/books perhaps) ?
Can newbies skip logging initially ?

 
Tim Holloway
Saloon Keeper
Pie
Posts: 17646
39
Android Eclipse IDE Linux
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rahul Sudip Bose wrote:
Can newbies skip logging initially ?


Hey, how else can we tell you're newbies?

Log4j is pretty easy to use. You just plop down a jar in the classpath and create a log4.properties or log4j.xml file in the classpath root that defines what logfile(s) you're using - assuming you log to files - and what log IDs (usually that's the package name of the class where the log statement is).

JULI is even easier, since it's built right into the JRE and the config file is in the JRE lib directory.

Actual use is trivial. You have several different logging levels, running from DEBUG/FINEST to ERROR. A logger can be configured to report only messages at or above a selected level.

Log statements are as simple as replacing "System.out.println()" with "log.info()", although you do need a definition for "log" in your class. I have an IDE hotkey set up for that since I do it so often.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic