Skip to content
Advertisement

Which level of the logger is appropriate to ask the user to enter an input in java?

I would like to ask the user to enter an access token, however I cannot use System.out.println(), but I should use a logger instead. I’m using the class java.util.logging.Logger.

When I use the logger I have to specify a level, but which level is more appropriate to use?

I have done this:

myLogger.log(Level.INFO,"Insert the token");
String token = null;
token = variable.readLine();

but i’m not sure that Level.INFO is the appropriate level.

Here levels you can find the description for each level, but I don’t know how to make a decision, do you think “CONFIG” is okay?

Advertisement

Answer

IMHO logging is the wrong approach here.

a logging framework is here to for logs and abstracts the output, it doesn’t guarantee you that your corresponding log is redirected to STDOUT (it depends on the configuration)

Having user interactions is a valid case to work with System.out and System.in.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement