EJB - System out printl - how to make it work

1.3k views Asked by At

In university i'm doing EJB project on Java. I have some Beans (Remote interface and it implementation, which do the main business logic). And i want to print some debugging text\information. For example:

@Stateless(mappedName = "BusinessLogicBean")     // имя, по которому можно обращаться к этому бину извне)

public class BusinessLogicSessionBean implements BusinessLogicSessionBeanRemote, BusinessLogicSessionBeanLocal {
    @PersistenceContext(unitName = "FoodDiary-ejbPU")
    private EntityManager em;

    @Override
    public void addNewProduct(String name, Boolean isProducr, String kkal, String prot, String fat, String carb) {
 System.out.printl("Now we are running method ADD NEW PRODUCT");
....
}

But when I use all methods - they are doing all business logic, but doesn't PRINT anywhere my phrase (which i'm writing with SOUT). I'm looked in Glassfish log, in log if executing my program - and there is nothing.

Could anyone tell - how can I print my information from Session Beans ?

2

There are 2 answers

2
njjnex On

Try to use debugger to make shure your System.out.println reached by app. Generally it looks ok.

0
SuperAndrew On

According to glassfish documentation:

https://docs.oracle.com/cd/E19798-01/821-1752/beafc/index.html

Enabling Verbose Mode

To have the server logs and messages printed to System.out on your command prompt screen, you can start the server in verbose mode. This makes it easy to do simple debugging using print statements, without having to view the server.log file every time.

To start the server in verbose mode, use the ----verbose option as follows:

asadmin start-domain --verbose [domain-name]

When the server is in verbose mode, messages are logged to the console or terminal window in addition to the log file. In addition, pressing Ctrl-C stops the server and pressing Ctrl-\ (on UNIX platforms) or Ctrl-Break (on Windows platforms) prints a thread dump. On UNIX platforms, you can also print a thread dump using the jstack command (see http://java.sun.com/javase/6/docs/technotes/tools/share/jstack.html) or the command kill -QUIT process_id.