Java / tomcat console on Mac OS X

Hi all,

I was just wondering where the java/tomcat console is hiding in OS X. I do use an OS X as well as a Windows machine for development. Both running the latest OS version, as well as the latest Cube Studio version. On the Windows machine a console window opens up as soon as I run an app from the Cuba studio. Under OS X this does not happen. While debugging and developing, some times I like to use the good old System.out.println() to print something on the console. So I’m wondering if I can enable the console on OS X as well.

Maybe some of you knows how?

Thanks a lot!

Hi,

By default we show terminal window with tomcat executable only on Windows. On another OS you can find tomcat logs in Studio.

If you want to show console window on Mac OS you can use special environment variable CUBA_TOMCAT_START_SCRIPT. This option is recommended only for users that are familiar with shell and scripting. On my Linux machine it is set to:


/home/artamonov/.scripts/tomcat-start.sh

And tomcat-start.sh opens new terminal window with catalina.sh (this script is relevant only for XFCE desktop on Linux):


#!/bin/bash
xfce4-terminal --working-directory="$1/bin" -e "./catalina.sh jpda run" & > /dev/null 2>&1

log-access

Hi Yuriy,

Thanks for your answer. Unfortunately I could not get it to work on Mac OS X…

First I was a struggle to set the environment variable correctly. As it is easy under Linux and Windows, it’s really hard under OS X. After a while I found this https://github.com/ersiner/osx-env-sync and that helped me a lot to get the environment variable set correctly.

Next I gave it a try and put some test script (echo-ing the parameters) in a script called by the script in the environment variable. The first should open a terminal and show the parameters. In the end of course it should start Tomact (startup.sh or catalina.sh in /deploy/tomcat/bin). But while the environment variable was set, it didn’t make any difference. Tomcat was started as usual by Cuba Studio.

For me though it’s not a big deal anymore since I discovered that the console output is written to /deploy/tomcat/logs/catalina.out.

So when debugging/developing while using the good old System.out.println to show me the values of certain variables, I can do so on my Mac too. I just will fire up a terminal and the tail command:


tail -f <project>/deploy/tomcat/logs/catalina.out.

That works fine for what I want to achieve.

I hope this reply is still useful for someone, whether searching for how to set an environment variable on Mac OSX or a way to see the values printed to the console by System.out.println or alike.

Have you tried Studio console panel that can show tomcat log? It is updating log entries automatically, don’t need to use separate terminal window.

Hi,

Yes I did, and yes it shows the tomcat log and of course that’s useful. But unfortunately it does not show the catalina.out log. This is the log file that contains everything that was sent to std out (the console). Would be nice though, if that would be included. :wink:

We will check it and try to add to Studio. Also I recommend you debugging using Logger statements. Just inject Logger instance to your controller or bean and post messages:


import org.slf4j.Logger;
...
@Inject
private Logger logger;
...
logger.warn("Some message!");
1 Like

Thanks, great tip, works great, I can now see the logging in the app.log within Cuba Studio. Didn’t know about this, still a Cuba-noob :wink: