0

I use Liferay portlet bundle 6.2 (Tomcat), I save some variable in portlet preference. It's going on without problem, but if I print the entries with System.out.println, it doesn't come a output on console. Where comes output with System.out.println in Liferay? How I can work with System.out.println in Liferay, is there another solution instead of System.out.println?

In follow I post the code, where comes

Thank you

    public void addEntry(ActionRequest request, ActionResponse response) {

    try {

       PortletPreferences prefs = request.getPreferences();
       String[] guestbookEntries = prefs.getValues("guestbook-entries",
          new String[1]);

       ArrayList<String> entries = new ArrayList<String>();

       if (guestbookEntries != null) {

         entries = new ArrayList<String>(Arrays.asList(prefs.getValues(
              "guestbook-entries", new String[1])));
       }

       String userName = ParamUtil.getString(request, "name");
       String message = ParamUtil.getString(request, "message");
       String customer = ParamUtil.getString(request, "customer");
       String entry = userName + "^" + message + "^" + customer;

       entries.add(entry);

       System.out.println("hallo");

       String[] array = entries.toArray(new String[entries.size()]);

       prefs.setValues("guestbook-entries", array);

       try {

         prefs.store();

       } catch (IOException ex) {

         Logger.getLogger(GuestbookPortlet.class.getName()).log(
              Level.SEVERE, null, ex);

       } catch (ValidatorException ex) {

         Logger.getLogger(GuestbookPortlet.class.getName()).log(
              Level.SEVERE, null, ex);

       }

    } catch (ReadOnlyException ex) {

       Logger.getLogger(GuestbookPortlet.class.getName()).log(
          Level.SEVERE, null, ex);

    }
}
Peter K.
  • 8,028
  • 4
  • 48
  • 73
Sengül Mor
  • 47
  • 1
  • 10
  • You are asking for a solution that you are using already: a logger. There is quite much information about logging available in the [Liferay Wiki](https://www.liferay.com/de/community/wiki/-/wiki/Main/How+to+configure+the+logs+in+Liferay). – Tobias Liefke Oct 09 '15 at 08:09

1 Answers1

0

System.out aren't the most elegant way to debug, but they works in Liferay.

Are you sure you are reading tomcat/logs/catalina.out file?

Pierpaolo Cira
  • 1,457
  • 17
  • 23
  • I don't find catalina.out in tomcat/logs. I have only catalina.log there. tomcat-7.0.42\logs\catalina.log. How I can manage to become catalina.out? – Sengül Mor Oct 10 '15 at 11:54
  • What is your operative system? In which way doues your tomcat start (by eclipse configuration, by using command line, by a double click on the icon)? Doues your Liferay using a standard configuration? Let me know... – Pierpaolo Cira Oct 10 '15 at 18:53
  • I use windows 7 and Liferay IDE(eclipse), I start the tomcat 7 server with green start icon in eclipse. I didn't change any option, Liferay using standart configuration. – Sengül Mor Oct 13 '15 at 07:35
  • And I use Lİferay Plugins SDK 6.2 – Sengül Mor Oct 13 '15 at 07:54
  • @SengülMor in this case you should see your system.out inside Eclipse console... didn't you? – Pierpaolo Cira Oct 13 '15 at 08:22
  • I didn't see, this is my main problem. – Sengül Mor Oct 13 '15 at 11:05
  • The standard behaviour is that System.out.println() will print text on "System.out" (to simplify it is the standard output; see this excellent answer to get more info http://stackoverflow.com/questions/17121311/how-does-system-out-print-work ). So, for a default LR configuration, stdout is the logfile we spoken above. Different is if you launch LR by Eclipse: stdout will be the Console view. In my mind you are using some kind of non standard configuration of Eclipse/Tomcat/Liferay... can you provide more information about? Do you try to launch Eclipse by its startup.bat in command line? – Pierpaolo Cira Oct 13 '15 at 12:08
  • No, I don't start startup.bat – Sengül Mor Oct 14 '15 at 11:43
  • Try to launch Eclipse by its startup.bat (in command line) and see if you have logs in console... then... can you provide more information about non-standard configuration of Eclipse/Tomcat/Liferay (or are you using a clean bundle)? – Pierpaolo Cira Oct 14 '15 at 12:20
  • Thanks, Pierpaolo Ciro for your efforts to help me. Now, I solve this problem. I see the output on console. I use Log, and now I understand it. – Sengül Mor Oct 15 '15 at 07:40