File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Changing log level on Logger Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Changing log level on Logger" Watch "Changing log level on Logger" New topic

Changing log level on Logger

Jim Petersson
Ranch Hand

Joined: May 28, 2008
Posts: 48
Im trying to figure out how the Logger works but ran into some problems.
I'm trying to use the entering and exiting methods. From the API they are said to be of FINER-level. So in order to have them displayed I reckoned all I'd have to do is call myLogger.setLevel(Level.FINER). Unfortunately this didn't make my entering and exiting messages show.
What am I doing wrong?


SCJP 5<br />SCJD
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11778

Hi Jim,

I'm betting on 2 things:
  • You are using the ConsoleHandler

  • The default level for the ConsileHandler is Level.INFO

  • You are setting the log level on the Logger instance

  • Setting the log level on the logger only tells the logger what level of messages are to be passed to the handler. It doesn't change anything on the handler.

    So, if I am right, your logger is correctly set such that it sends messages to the handler, however the handler then ignores them.

    Simple fix: set the level on the handler as well:
    With the output:

    Regards, Andrew
    [ June 19, 2008: Message edited by: Andrew Monkhouse ]

    The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
    Jim Petersson
    Ranch Hand

    Joined: May 28, 2008
    Posts: 48
    You were absolutely right. Changing level on the assosiated handlers aswell solved my problem. Thanks Andrew.
    I agree. Here's the link:
    subject: Changing log level on Logger
    It's not a secret anymore!