How to console log a value for debugging?

I am new to cuba framework and java itself. What is the alternative for console.log in javascript for logging out a value while runtime of cuba web module. I added ?debug to my url and got the console screen, but how can i write to this screen while runtime? or should i do it some other way?

If you want to log some value from a screen controller (web module) you can create the slf4j logger and use it here. The logger can be created by this way:

Logger logger = LoggerFactory.getLogger(YourController.class);

and used by this way:"Variable foo = {}", variableValue);

The logged value will be shown in the console from which you launched the application.
If you want to output a value from your variable in the web-toolkit module (it contains widgets) you can use default java logger:

java.util.logging.Logger logger = Logger.getLogger("WidgetName");
logger.log(Level.INFO, yourMessage);

Best regards,

1 Like

Also, you can use dependency injection for Logger in Spring beans and screen controllers:

private org.slf4j.Logger log;
1 Like