我正在Centos 6.x中的Jetty服务安装中部署scala lift应用程序。我已经尝试了一切,以便更改日志级别和模式,但总是得到调试和截断的消息。
我已经按照官方文档来配置logback,就像我更改了与日志记录相关的每个配置文件一样没有运气。运行应用程序时,maven完美地运行mvn jetty:run
,但在服务器中部署战争时可以配置日志记录。
我已经开头尝试了:
Jetty 6 always generates debug logs? http://www.eclipse.org/jetty/documentation/current/configuring-logging.html
有人遇到过这种问题吗?
[编辑]
在src / main / resources / props里面我有一个名为default.props的空文件。 (0字节)
在src / main / resources /里面有一个jetty-logback.xml文件。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d %5p | %.-1000m %n</pattern>
</encoder>
</appender>
<logger name="mx.ssf.sicom.brokerGaspar">
<level value="INFO" />
</logger>
<logger name="mx.ssf.sicom.gasparIntegration">
<level value="INFO" />
</logger>
<logger name="mx.ssf.sicom.commProtocol">
<level value="INFO" />
</logger>
<!-- <logger name="org.hibernate"> -->
<!-- <level value="DEBUG" /> -->
<!-- </logger> -->
<logger name="mx.ssf.sicom.operationalServices">
<level value="INFO" />
</logger>
<logger name="mx.ssf.sicom.catalogsServices.brokerapiImpl">
<level value="INFO" />
</logger>
<root>
<level value="INFO" />
<appender-ref ref="CONSOLE" />
</root>
</configuration>
使用maven运行时此文件有效。当直接在jetty中部署时,我会根据所有登录jetty的教程将此文件移动到Jetty_HOME / resources。
启动jetty时没有额外的JVM运行时参数。
[编辑2]
在source / main / resources / props中,我有一个名为production.default.logback.xml的文件。该文件的内容与第一个EDIT中列出的后退文件jetty-logback.xml相同。
我在没有running.mode属性的情况下运行。即便如此,我也尝试过使用run.mode = development,但结果是一样的。
我不使用SBT,我使用scala maven插件。 pom的配置有点复杂,因为我们有三个级别的pom配置。从电梯网络应用程序(孩子)的pom开始:
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>MyLiftApp</artifactId>
<parent>
<artifactId>LiftApp-project</artifactId>
<groupId>mygroupid</groupId>
<version>0.1.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<packaging>war</packaging>
<name>MyAppName</name>
<properties>
<maven.scaladoc.vscaladocVersion>1.2-m1</maven.scaladoc.vscaladocVersion>
<vscaladoc.links.liftweb.pathsufix>scaladocs/</vscaladoc.links.liftweb.pathsufix>
<vscaladoc.links.liftweb.baseurl>http://scala-tools.org/mvnsites/liftweb</vscaladoc.links.liftweb.baseurl>
<scala.version>2.9.1</scala.version>
</properties>
<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.15.2</version>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<launchers>
<launcher>
<id>mainLauncher</id>
<mainClass>
mx.ssf.sicom.brokerGaspar.Main
</mainClass>
<jvmArgs>
<jvmArg>-DdataAccess.props.dir=${project.build.directory}/classes/</jvmArg>
</jvmArgs>
</launcher>
</launchers>
<scalaVersion>${scala.version}</scalaVersion>
<sendJavaToScalac>true</sendJavaToScalac>
<args>
<!--arg>-target:jvm-1.5</arg -->
<arg>-g:vars</arg>
<arg>-deprecation</arg>
<arg>-dependencyfile</arg>
<arg>${project.build.directory}/.scala_dependencies</arg>
</args>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<parallel>methods</parallel>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.25</version>
<configuration>
<systemProperties>
<systemProperty>
<name>logback.configurationFile</name>
<value>${project.build.outputDirectory}/jetty-logback.xml</value>
</systemProperty>
</systemProperties>
<contextPath>/</contextPath>
<scanIntervalSeconds>0</scanIntervalSeconds>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>8100</port>
</connector>
</connectors>
</configuration>
</plugin>
<plugin>
<groupId>net.sf.alchim</groupId>
<artifactId>yuicompressor-maven-plugin</artifactId>
<version>0.7.1</version>
<executions>
<execution>
<goals>
<goal>compress</goal>
</goals>
</execution>
</executions>
<configuration>
<nosuffix>true</nosuffix>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>mx.ssf.sicom</groupId>
<artifactId>JPADataAccess</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.rxtx</groupId>
<artifactId>rxtx</artifactId>
<version>2.1.7</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.liftweb</groupId>
<artifactId>lift-mapper_2.9.1</artifactId>
<version>2.4-M4</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
<version>6.1.25</version>
<scope>test</scope>
</dependency>
<!-- for LiftConsole -->
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
<version>${scala.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.databinder</groupId>
<artifactId>dispatch-http_2.9.1</artifactId>
<version>0.8.8</version>
</dependency>
<dependency>
<groupId>mx.ssf.sicom</groupId>
<artifactId>CommProtocol</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>mx.ssf.sicom</groupId>
<artifactId>GasparIntegration</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>mx.ssf.sicom</groupId>
<artifactId>ScalaCommons</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>mx.ssf.sicom</groupId>
<artifactId>CorporateStructureServiceBrokerImpl</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>mx.ssf.sicom</groupId>
<artifactId>BrokerMessagingService</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>mx.ssf.sicom</groupId>
<artifactId>OperationalServicesBrokerImpl</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>mx.ssf.sicom</groupId>
<artifactId>CatalogsServiceBrokerImpl</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
之后,父项目有了这个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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>TheParent-project</artifactId>
<version>0.1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>TheParent-project</name>
<parent>
<groupId>thegroupid</groupId>
<artifactId>TheParent-Solution</artifactId>
<version>1</version>
</parent>
<modules>
<module>MyLiftApp</module>
<module>OtherModule</module>
<module>OtherModule2</module>
<module>OtherModule3</module>
<module>OtherModule4</module>
<module>OtherModule5</module>
<module>OtherModule6</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5</version>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>mygroupid</groupId>
<artifactId>CommonDomain</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
最后,我所有项目的主管是:
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>mygroupid</groupId>
<artifactId>TheGreat-Solution</artifactId>
<version>1</version>
<packaging>pom</packaging>
<properties>
<spring.version>3.1.1.RELEASE</spring.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<hibernate.version>4.1.4.Final</hibernate.version>
<hibernate.validator.version>4.3.0.Final</hibernate.validator.version>
</properties>
<organization>
<name>My company</name>
<url>www.www.www</url>
</organization>
<issueManagement>
<url>http://mybt.com</url>
<system>MantisBT</system>
</issueManagement>
<ciManagement>
<system>Jenkins</system>
<url>http://myci.com</url>
</ciManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.6</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.6</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.6.4</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.0</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>${hibernate.validator.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-envers</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
<version>${hibernate.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<!-- To define the plugin version in your parent POM -->
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
我知道它看起来很复杂,但我几乎可以肯定这个问题与依赖关系管理无关,因为通过logback进行的日志记录可以在tomcat中部署的所有模块中运行。只有部署在码头上的电梯webapp失败了......我检查了可部署升力战的包含内容,它包含了回退所需的所有依赖关系。
答案 0 :(得分:1)
试试这个:
如果这不起作用,可以使用Boot类中的以下代码直接传递Lift文件
Logger.setup = Full(Logback.withFile(pathToLogbackxml))