0

I am using spring boot and logback. I am able to log into file in my local environment with IDE (IntelliJ), but it fails to log on AWS EC2 redhat linux with a JBoss EAP 7.1. I tried to set the log file permission to 777 after it is created, but still not working. The way I start up the server is

sudo sh /home/ec2-user/jboss-eap-7.1/bin/standalone.sh

my logback-spring.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

    <!--Local-->
    <!--<property name="LOG_FOLDER" value="${user.dir}/log" />-->
    <!--Server-->
    <property name="LOG_FOLDER" value="/home/ec2-user/jboss-eap-7.1/applications/springboottest/log"/>

    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
        <layout class="ch.qos.logback.classic.PatternLayout">
            <Pattern>[%d{HH:mm:ss.SSS}] THREAD=[%6.-6X{threadID}] %-5level [%30.-30logger{0}] - %msg%n</Pattern>
        </layout>
    </appender>

    <appender name="ALL" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <append>true</append>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${LOG_FOLDER}/log.all.%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>60</maxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>[%d{HH:mm:ss.SSS}] THREAD=[%6.-6X{threadID}] %-5level [%30.-30logger{0}] - %msg%n</pattern>
        </encoder>
    </appender>


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

</configuration>

Does anyone know why it cannot append to the file?

Any help is appreciated. Thanks

Hon Lun Chan
  • 148
  • 2
  • 16
  • Is nothing being logged or is it just not appending to the log file? – James R. Perkins Aug 09 '18 at 23:20
  • Nothing being logged, even the spring start up log. The log files are 0 bytes large. – Hon Lun Chan Aug 10 '18 at 12:32
  • Do you have a `jboss-deployment-structure.xml` in your deployment? You might want to have a look at https://stackoverflow.com/a/9520699/152794 – James R. Perkins Aug 10 '18 at 14:59
  • I have a `jboss-web.xml` having only one property `context-root` – Hon Lun Chan Aug 10 '18 at 15:02
  • You'll need a `jboss-deployment-structure.xml` which excludes either the logging subsystem or excludes the slf4j modules. Then you'll need to ensure you include them in your deployment. – James R. Perkins Aug 10 '18 at 22:09
  • it works after i excluded the slf4j modules!! can you explain the reason as well please? – Hon Lun Chan Aug 13 '18 at 07:22
  • The `org.slf4j.api` module is added by default which binds to a module that uses the jboss-logmanager. Excluding the module allows you do include slf4j which can bind to a different implementation. – James R. Perkins Aug 13 '18 at 17:19
  • So I can include the `slf4j` module into my application and use my configured `logback` as implementation after excluding the default `slf4j` implementation in `JBoss`, but will it makes some program from `JBoss` not working ? – Hon Lun Chan Aug 15 '18 at 04:01
  • No. If you want slf4j to bind to a different log manager you need to exclude the dependency and provide your own slf4j-api.jar. – James R. Perkins Aug 15 '18 at 19:57

0 Answers0