Ignore:
Timestamp:
06/19/13 15:59:53 (11 years ago)
Author:
stoda
Message:

log4j added

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/main/java/omq/common/broker/Broker.java

    r47 r49  
    22
    33import java.io.IOException;
     4import java.net.URL;
    45import java.util.HashMap;
    56import java.util.Map;
     
    2021import omq.server.RemoteObject;
    2122
     23import org.apache.log4j.Logger;
     24import org.apache.log4j.xml.DOMConfigurator;
     25
    2226import com.rabbitmq.client.Channel;
    2327import com.rabbitmq.client.Connection;
     
    2832
    2933public class Broker {
     34
     35        private static final Logger logger = Logger.getLogger(Broker.class.getName());
     36
    3037        private static Connection connection;
    3138        private static Channel channel;
     
    4552        public static synchronized void initBroker(Properties env) throws Exception {
    4653                if (environment == null) {
     54
     55                        // Load log4j configuration
     56                        URL log4jResource = Broker.class.getResource("/log4j.xml");
     57                        DOMConfigurator.configure(log4jResource);
     58
    4759                        remoteObjs = new HashMap<String, RemoteObject>();
    4860                        environment = env;
     
    5870                        }
    5971                } else {
    60                         throw new InitBrokerException("Broker already started");
     72                        logger.error("Broker is already started");
     73                        throw new InitBrokerException("Broker is already started");
    6174                }
    6275        }
    6376
    6477        public static void stopBroker() throws Exception {
     78                logger.warn("Stopping broker");
    6579                // Stop the client
    6680                if (clientStarted) {
     
    93107
    94108        public static void closeConnection() throws IOException {
     109                logger.warn("Clossing connection");
    95110                connectionClosed = true;
    96111                connection.close();
     
    241256                        @Override
    242257                        public void shutdownCompleted(ShutdownSignalException cause) {
     258                                logger.warn("Shutdown message received. Cause: " + cause.getMessage());
    243259                                if (!connectionClosed)
    244260                                        if (cause.isHardError()) {
Note: See TracChangeset for help on using the changeset viewer.