Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2007

Tip: Looking for answers? Try searching our database.

Logging when developing Web apps under NetBeans

Thread view: 
Kenneth P. Turvey - 29 Oct 2007 22:39 GMT
I don't think NetBeans is the problem, but I thought I should include it.

I have some code that uses the Java logging system to print out some
tracing information.  

logger.finest("This is some tracing info");

So I want to see what is coming out.  

I thought that NetBeans would print it in the output window, but it
doesn't.  That would be ideal.

So I want to look at it in a file that is created.  

I went to the $JAVA_HOME/jre/lib directory and edited the
logging.properties file, adding:

com.squeakydolphin.level = ALL

Thinking this would work, but it doesn't.  There is no file created in my
home directory.  

So then I went to the web and found that TomCat (which is the servlet
container used by NetBeans for development) doesn't use the standard Java
properties file to determine where logging goes.  So I added the following
to the tomcat logging.properties file:

com.squeakydolphin.level = ALL

No logs are generated in the logs directory under tomcat and there is
nothing in my home directory.  

Does anyone know how I turn this stuff on?  

Thanks.

Signature

Kenneth P. Turvey <kt-usenet@squeakydolphin.com>

Arne Vajhøj - 30 Oct 2007 02:15 GMT
> I don't think NetBeans is the problem, but I thought I should include it.
>
[quoted text clipped - 29 lines]
>
> Does anyone know how I turn this stuff on?  

I think you need to study java.util.logging and log4j a bit.

For java.util.logging try:

xxxx.level = FINE
handlers = java.util.logging.ConsoleHandler,
java.util.logging.ConsoleHandler.level = INFO
java.util.logging.ConsoleHandler.formatter =
java.util.logging.SimpleFormatter

What xxxx should be depends on your:

Logger logger = Logger.getLogger("xxxx");

code.

Log4j is similar but still different.

But try get java.util.logging working first.

Arne
Mark Space - 30 Oct 2007 03:59 GMT
> I don't think NetBeans is the problem, but I thought I should include it.
>
[quoted text clipped - 14 lines]
>
> com.squeakydolphin.level = ALL

I think this only works for classes, not packages.

Set the default level for a whole application with
.level = ALL

Also, you won't get a file output by default, unless you turn that on too:
java.util.logging.FileHandler.level = ALL
java.util.logging.FileHandler.pattern = $h/MyLog.log
java.util.logging.FileHandler.limit = 25000
java.util.logging.FileHandler.count = 4
java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter

or there abouts.

For a quick test, you might also want to install a console handler:
java.util.logging.ConsoleHandler.level = ALL

If you don't want mess with the (global) logging properties, you can set
a specific file on the command line and set your properties on a per
project basis.

java -Djava.util.logging.config.file=myfile.properties


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.