3

如何将日志记录从 Tomcat 7 上的 Java webapp 路由到 ElasticBeanstalk 管理控制台或 Eclipse 插件中可见的日志?我的应用程序被编码为 SLF4J API 并由 Logback 支持。

我真的很想不必通过 SSH 连接到每个盒子并跟踪一个日志文件;我一直在添加和删除实例,所以这将是一个正确的痛苦。

我的 logback.xml 看起来像这样:

<configuration>

    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <!-- encoders are assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>

    <logger name="org.springframework" level="INFO" />
    <logger name="org.springframework.social" level="INFO" />
    <logger name="org.socialsignin" level="INFO" />

    <root level="ALL">
        <appender-ref ref="STDOUT" />
    </root>
</configuration>
4

2 回答 2

2

我使用 slf4j-jdk14 作为后端,它在部署到 ElasticBeanstalk 时工作正常。

以下将使您使用的所有其他库登录到同一后端:

        <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-jdk14</artifactId>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jcl-over-slf4j</artifactId>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>log4j-over-slf4j</artifactId>
    </dependency>

希望这对你有用。

于 2012-10-23T10:12:16.720 回答
0

I would strongly recommend to forward your logs to papertrailapp.com through syslog. Read more about it in jcabi-beanstalk-maven-plugin. There are many benefits of this solution comparing to the one you're using, including: 1) logs are easier to read, 2) logs can be integrated in one place from many servers, 3) other systems can log into the same destination, etc.

于 2012-12-18T19:58:28.727 回答