瀏覽代碼

路由日志到activemq调试

lingfeng 8 年之前
父節點
當前提交
48de75acb2

+ 6 - 0
hos-broker/pom.xml

@ -55,6 +55,12 @@
			<groupId>com.yihu.hos</groupId>
			<artifactId>hos-web-framework</artifactId>
			<version>1.1.1-SNAPSHOT</version>
			<exclusions>
				<exclusion>
					<groupId>org.apache.logging.log4j</groupId>
					<artifactId>log4j-api</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
	</dependencies>

+ 1 - 10
hos-broker/src/main/java/com/yihu/hos/common/listener/ApplicationStartListener.java

@ -1,6 +1,5 @@
package com.yihu.hos.common.listener;
import com.yihu.hos.common.configuration.ActivemqConfiguration;
import com.yihu.hos.common.constants.Constant;
import com.yihu.hos.common.dao.BrokerDao;
import com.yihu.hos.core.datatype.ClassFileUtil;
@ -9,15 +8,12 @@ import com.yihu.hos.models.SystemCamelContext;
import com.yihu.hos.models.SystemClassMapping;
import com.yihu.hos.models.SystemServiceFlow;
import com.yihu.hos.models.SystemServiceFlowClass;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.jms.JmsComponent;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import javax.jms.ConnectionFactory;
import java.io.File;
import java.net.URL;
import java.net.URLClassLoader;
@ -110,12 +106,7 @@ public class ApplicationStartListener implements ApplicationListener<ContextRefr
        // 4、=============
        // 首先启动Apache Camel服务
        SystemCamelContext.getDefaultCamelContext().start();
        ActivemqConfiguration activemqConfiguration = contextRefreshedEvent.getApplicationContext().getBean(ActivemqConfiguration.class);
        ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
                activemqConfiguration.getUser(), activemqConfiguration.getPassword(), activemqConfiguration.getBrokerURL());
        // Note we can explicit name the component
        SystemCamelContext.getDefaultCamelContext().addComponent("business-log", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
        SystemCamelContext.getDefaultCamelContext().setUseMDCLogging(true);
        logger.info("Apache Camel Context 启动完成......");
        // 加载和设置ClassLoader
        List<URL> URLs = new ArrayList<>();

+ 1 - 0
hos-broker/src/main/resources/jndi.properties

@ -0,0 +1 @@
topic.logTopic=logTopic2

+ 40 - 0
hos-broker/src/main/resources/log4j.properties

@ -0,0 +1,40 @@
## ------------------------------------------------------------------------
## Licensed to the Apache Software Foundation (ASF) under one or more
## contributor license agreements.  See the NOTICE file distributed with
## this work for additional information regarding copyright ownership.
## The ASF licenses this file to You under the Apache License, Version 2.0
## (the "License"); you may not use this file except in compliance with
## the License.  You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
## ------------------------------------------------------------------------
#
# The logging properties used for testing.
#
log4j.rootLogger=INFO, stdout, jms
# uncomment the following to enable camel debugging
#log4j.logger.org.apache.camel.component.http4=DEBUG
# CONSOLE appender not used by default
log4j.logger.org.apache.activemq=INFO, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %-5p %c - %m%n
log4j.appender.jms=org.apache.log4j.net.JMSAppender
log4j.appender.jms.InitialContextFactoryName=org.apache.activemq.jndi.ActiveMQInitialContextFactory
log4j.appender.jms.ProviderURL=tcp://172.19.103.86:61616
log4j.appender.jms.TopicBindingName=logTopic
log4j.appender.jms.TopicConnectionFactoryBindingName=ConnectionFactory
log4j.appender.jms.layout=org.apache.log4j.patternLayout
log4j.appender.jms.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - camel.exchangeId:%-10.10X{camel.exchangeId} - camel.routeId:%-10.10X{camel.routeId} - %m%n
log4j.appender.jms.userName=admin
log4j.appender.jms.password=admin

+ 0 - 30
hos-core-dependencies/pom.xml

@ -177,7 +177,6 @@
            <artifactId>log4j-core</artifactId>
            <version>${log4j2.version}</version>
        </dependency>
        <!--SLF4J api-->
        <dependency>
            <groupId>org.slf4j</groupId>
@ -185,35 +184,6 @@
            <version>${slf4j.version}</version>
        </dependency>
        <!--Log framework to SLF4J bridge: x-over-slf4j-->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>${slf4j.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-jdk14</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jul-to-slf4j</artifactId>
            <version>${slf4j.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>log4j-over-slf4j</artifactId>
            <version>${slf4j.version}</version>
        </dependency>
        <!-- Log framework end-->
    </dependencies>
</project>

+ 22 - 0
hos-web-framework-dependencies/pom.xml

@ -64,10 +64,26 @@
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <artifactId>jcl-over-slf4j</artifactId>
                    <groupId>org.slf4j</groupId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>log4j-over-slf4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>jcl-over-slf4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
@ -77,6 +93,12 @@
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-mongodb</artifactId>
            <version>1.9.2.RELEASE</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>jcl-over-slf4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.mongodb</groupId>