• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

HttpSessionListener : Where can i see this output ?

 
Ranch Hand
Posts: 637
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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/
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
use out.println("");

instead of system.out.println();//this out put will be shown on server console
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Those would be appear on server console.
 
Rahul Sudip Bose
Ranch Hand
Posts: 637
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
Saloon Keeper
Posts: 28410
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 28410
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 just had the craziest dream. This tiny ad was in it.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic