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

Tags:



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?

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.



Source: stackoverflow