Enterprise Java Development@TOPIC@
Two primary ways to run the application server
Standalone. Can be local or remote
Embedded within IDE. Shares same JVM.
root-logger sets default versbosity to INFO
additional logger sets verbosity for info.ejava.* to DEBUG
Figure 91.2. Application Code
package info.ejava.examples.ejb.basic.ejb;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Stateless
@Remote(GreeterRemote.class)
public class GreeterEJB implements Greeter {
private static final Logger logger = LoggerFactory.getLogger(GreeterEJB.class);
@PostConstruct
public void init() {
logger.info("*** GreeterEJB ***");
}
@Override
public String sayHello(String name) throws BadRequestException {
logger.debug("sayHello({})", name);
...
}
EJB class used to create logger named after the class' fully qualified name
@PostConstruct logging at INFO level
business method logging at DEBUG level
Figure 91.3. Server Console Output
./bin/standalone.sh ... 01:17:01,990 INFO [info.ejava.examples.ejb.basic.ejb.GreeterEJB] (EJB default - 1) *** GreeterEJB ***
Console configured (by default) to only output INFO and above
Figure 91.4. Server log/server.log Output
$ tail -n 999 -f standalone/log/server.log 2014-10-01 01:17:01,990 INFO [info.ejava.examples.ejb.basic.ejb.GreeterEJB] (EJB default - 1) *** GreeterEJB *** 2014-10-01 01:17:02,009 DEBUG [info.ejava.examples.ejb.basic.ejb.GreeterEJB] (EJB default - 1) sayHello(cat inhat)
server.log will print all verbosity levels
All server actions can be scripted with command-line interface
Figure 91.7. Kill Standalone Server using Control-C
01:39:20,291 INFO [org.jboss.as.messaging] (MSC service thread 1-4) JBAS011601: Bound messaging object to jndi name java:jboss/DefaultJMSConnectionFactory ^C 01:39:32,666 INFO [org.wildfly.extension.undertow] (MSC service thread 1-4) JBAS017532: Host default-host stopping 01:39:32,666 INFO [org.jboss.as.messaging] (ServerService Thread Pool -- 57) JBAS011605: Unbound messaging object to jndi name java:jboss/exported/jms/RemoteConnectionFactory
Server can also be safely shutdown with Control-C in console window