tags:

views:

458

answers:

2

how can I configure the behaviour of the root logger in the logging api? I don't want to configure the behaviour of each logger separately, instead it would be very convenient if I have a single property file where I can set the behaviour of all loggers.

A: 

I would suggest to use Apache Commons Logging or log4j directly. It's much more comfortable and flexible.

EDIT:

If you want to configure your logging from a properties file, you should go with Vinay Sajip's answer. To get the root Logger inside your program and configure it using the API, you could ask for the Logger named "", like it says here

private final static Logger logger = Logger.getLogger("");
Tim Büthe
Why is it much more comfortable? I have set up everything for logging with the logging api, it would not be comfortable to change everything.
Xelluloid
@Xelluloid: Yes, you're right, it would be more comfortable if you had used log4j in the first place. I don't knew that you already went to far to change this sort of thing... my bad.
Tim Büthe
this does not work as I mentioned in my comment under my question it seems that I do not access the root logger by ""
Xelluloid
oh sorry I've done a mistake =) now it works fine, thanks to you
Xelluloid
+1  A: 

I presume you mean the java.util.logging (JUL) implementation: if so, have a look at the relevant part of the Java Almanac. The overview information for JUL configuration is here. Basically, the approach is to use a single configuration file for all loggers.

Vinay Sajip