0
我已經設置了日誌記錄,我已經開發了一個項目的調用方法或行號,但我似乎無法得到行號和調用方法在日誌中顯示出來。我有一個Maven項目,以及maven-compiler-plugin
被配置爲包括在已編譯的類調試信息。記錄不會顯示
這將會是非常有益的,讓我有在日誌信息,對我理解爲什麼這是不對的,現在發生的事情。有人能幫助向我解釋什麼是怎麼回事,我如何能得到方法名和行號在我的日誌?
這裏是我的POM:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
<cxf.version>3.0.1</cxf.version>
<log4j.version>2.0.2</log4j.version>
<wsdl.dir>generated\wsdl</wsdl.dir>
</properties>
<groupId>com.company</groupId>
<artifactId>webservices</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>Nuance-to-Edify Web Services</name>
<description>This project will handle communication between servers.</description>
<build>
<finalName>n2e-ws</finalName>
<plugins>
<!-- CREATE WAR -->
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<webResources>
<!-- INCLUDE SOURCE FILES WITH WAR -->
<resource>
<directory>${project.build.sourceDirectory}</directory>
<targetPath>WEB-INF/classes</targetPath>
</resource>
<!-- INCLUDE RESOURCES WITH WAR -->
<resource>
<directory>${project.build.sourceDirectory}\..\resources</directory>
<targetPath>WEB-INF/classes</targetPath>
</resource>
<!-- INCLUDE WSDLS WITH WAR -->
<resource>
<directory>${project.build.directory}\${wsdl.dir}</directory>
<targetPath>WEB-INF/wsdl</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
<!-- GENERATE WSDL FOR EACH SERVICE -->
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-java2ws-plugin</artifactId>
<version>${cxf.version}</version>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>generate-account-service-wsdl</id>
<phase>prepare-package</phase>
<configuration>
<className>com.company.ws.data.services.interfaces.AccountServiceEndpointInterface</className>
<outputFile>${project.build.directory}\${wsdl.dir}\AccountService.wsdl</outputFile>
<address>REPLACE_WITH_ACTUAL_URL</address>
<genWsdl>true</genWsdl>
<verbose>true</verbose>
</configuration>
<goals>
<goal>java2ws</goal>
</goals>
</execution>
<execution>
<id>generate-logging-service-wsdl</id>
<phase>prepare-package</phase>
<configuration>
<className>com.company.ws.data.services.interfaces.LoggingServiceEndpointInterface</className>
<outputFile>${project.build.directory}\${wsdl.dir}\LoggingService.wsdl</outputFile>
<address>REPLACE_WITH_ACTUAL_URL</address>
<genWsdl>true</genWsdl>
<verbose>true</verbose>
</configuration>
<goals>
<goal>java2ws</goal>
</goals>
</execution>
<execution>
<id>generate-search-service-wsdl</id>
<phase>prepare-package</phase>
<configuration>
<className>com.company.ws.data.services.interfaces.SearchServiceEndpointInterface</className>
<outputFile>${project.build.directory}\${wsdl.dir}\SearchService.wsdl</outputFile>
<address>REPLACE_WITH_ACTUAL_URL</address>
<genWsdl>true</genWsdl>
<verbose>true</verbose>
</configuration>
<goals>
<goal>java2ws</goal>
</goals>
</execution>
<execution>
<id>generate-validation-service-wsdl</id>
<phase>prepare-package</phase>
<configuration>
<className>com.company.ws.data.services.interfaces.ValidationServiceEndpointInterface</className>
<outputFile>${project.build.directory}\${wsdl.dir}\ValidationService.wsdl</outputFile>
<address>REPLACE_WITH_ACTUAL_URL</address>
<genWsdl>true</genWsdl>
<verbose>true</verbose>
</configuration>
<goals>
<goal>java2ws</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<!-- mvn clean install tomcat:run-war to deploy Look for "Running war
on http://xxx" and "Setting the server's publish address to be /yyy" in console
output; WSDL browser address will be concatenation of the two: http://xxx/yyy?wsdl -->
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<executions>
<execution>
<id>start-tomcat</id>
<goals>
<goal>run-war</goal>
</goals>
<phase>pre-integration-test</phase>
<configuration>
<port>${test.server.port}</port>
<path>/*</path>
<fork>true</fork>
<useSeparateTomcatClassLoader>true</useSeparateTomcatClassLoader>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<debug>true</debug>
<debuglevel>lines,source,vars</debuglevel>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<projectNameTemplate>[artifactId]-[version]</projectNameTemplate>
<wtpmanifest>true</wtpmanifest>
<wtpapplicationxml>true</wtpapplicationxml>
<wtpversion>3.5</wtpversion>
</configuration>
</plugin>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.cxf
</groupId>
<artifactId>
cxf-java2ws-plugin
</artifactId>
<versionRange>
[${cxf.version},)
</versionRange>
<goals>
<goal>java2ws</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<versionRange>
[2.3.2,)
</versionRange>
<goals>
<goal>testCompile</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<!-- COMPILE DEPENDENCIES -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.3.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-digester3</artifactId>
<version>3.2</version>
<scope>compile</scope>
<classifier>with-deps</classifier>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.1.0.RELEASE</version>
<scope>compile</scope>
</dependency>
<!-- PROVIDED/TEST DEPENDENCIES -->
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jmock</groupId>
<artifactId>jmock-junit4</artifactId>
<version>2.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jmock</groupId>
<artifactId>jmock-legacy</artifactId>
<version>2.6.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
這是我的log4j2.xml配置文件:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration
status="debug"
monitorInterval="600">
<Appenders>
<Console
name="CONSOLE"
target="SYSTEM_OUT">
<PatternLayout
pattern="%d [%4.4t] [%5.5p] %35.35c(%15.15M):%-5.5L - %m%n" />
</Console>
<File
name="EDIFY-NUANCE"
fileName="../logs/n2e-ws.log">
<!--<PatternLayout
pattern="%d [%4.4t] [%5.5p] %35.35c(%15.15M):%-5.5L - %m%n" />-->
<PatternLayout pattern="%d %5p %20.30c [%t] %20.30C (%F:%L) %m%n"
/>
</File>
<Async name="ASYNC">
<AppenderRef ref="EDIFY-NUANCE" />
<AppenderRef ref="CONSOLE" />
</Async>
</Appenders>
<Loggers>
<logger
name="log4j.logger.httpclient.wire.header"
level="fatal"
additivity="false" />
<Root level="debug">
<AppenderRef ref="ASYNC" />
</Root>
</Loggers>
</Configuration>
你讓我在正確的軌道上,但我確實有修改意見,以讓我的問題解決了。我想特別感謝您提供與該主題相關的參考資料和文章。這就是說,'屬性includeLocation =「真」'必須添加到異步的appender:'<異步名=「異步」 includeLocation =「真」> ...'如果你修改你的答案,以反映這一點,我會將其標記爲已接受。 – liltitus27 2014-09-19 14:04:06
你說得對,感謝您的指正! – 2014-09-19 17:42:13