在服务码头安装中配置升降机应用程序日志



我正在Centos6.x中的Jetty服务安装中部署一个scala-lift应用程序。为了更改日志级别和模式,我尝试了一切,但总是得到调试和截断的消息。

为了配置logback,我遵循了官方文档,就像我更改了与日志记录相关的每一个配置文件一样。当运行应用程序时,thry-maven可以完美地运行mvn jetty:run,但当在服务器中部署war时,可以配置日志记录。

我已经阅读并尝试过:

Jetty 6总是生成调试日志?http://www.eclipse.org/jetty/documentation/current/configuring-logging.html

有人遇到过这种问题吗?

[编辑]

在src/main/resources/props中,我有一个名为default.props的空文件。(0字节)

在src/main/resources/I中有一个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的logback文件相同。

我在没有运行.mode属性的情况下运行。即使在那时,我也尝试过使用run.mode=development,但结果是一样的。

我不使用SBT,我使用scala-maven插件。pom的配置有点复杂,因为我们有三个级别的pom配置。从提升web应用程序(子应用程序)的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中部署的所有模块中都有效。只有部署在码头的升降机网络应用程序出现故障。。。。。。我检查了可部署lift-war的包含项,它包含logback所需的所有依赖项。

试试这个:

  1. 启动jetty实例时,不要包含-Drun.mode标志
  2. 将您的jetty-logback.xml文件复制到/src/main/resources/props/default.logback.xml

如果这不起作用,可以在引导类中使用以下代码直接向Lift传递配置文件

Logger.setup = Full(Logback.withFile(pathToLogbackxml))

最新更新