开发者

Logback is not generating log files on Ubuntu

We have configured logback for our logging needs in our application. When we run our application on Windows machine, it works as expected and generates the log files with proper logs. However when we deployed the same runnable jar file on Ubuntu machine, it is not generating log files. Following is the code in logback.xml

<configuration>
  <appender name="SIFT" class="ch.qos.logback.classic.sift.SiftingAppender">
    <!-- in the absence of the class attribute, it is assumed that the
         desired discriminator type is
         ch.qos.logback.classic.sift.MDCBasedDiscriminator -->
<discriminator>
  <key>uniqueNumber</key>
  <defaultValue>unknown</defaultValue>
</discriminator>
<sift>
  <appender name="FILE-${uniqueNumber}" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>${uniqueNumber}.log</file>
    <append>true</append>
     <rollingPolic开发者_开发问答y class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
                    <FileNamePattern>${uniqueNumber}_%i.log</FileNamePattern>
                    <MinIndex>1</MinIndex>
                    <MaxIndex>10000</MaxIndex>
            </rollingPolicy>
            <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
                    <MaxFileSize>5MB</MaxFileSize>
            </triggeringPolicy>
    <layout class="ch.qos.logback.classic.PatternLayout">
      <pattern>%d [%thread] %level %mdc %logger{35} - %msg%n</pattern>
    </layout>
  </appender>
</sift>
  </appender>
  <root level="DEBUG">
    <appender-ref ref="SIFT" />
  </root>
</configuration>


If anything goes wrong with the configuration logback prints out a lot of debug messages to System.out. If you do not see those, then perhaps the files ARE generated but you just don't know where.

You can explicitly enable logback printing with <configuration debug="true"> which should give you much more to work on.

If you just cannot locate the files consider using lsof to locate the full path of the open files of your application.


I had a similar problem to yours, even with a simpler logback configuration.

In my logback.xml file I used absolute paths instead of relative ones for the appender, but my configuration is Linux-only, and the machines where we deploy our Java application all share the same configuration/partitioning-scheme.

The files, at least this is what was happening to me, should be one directory up of your application directory. Lets say you are executing your JAR from PATH/my.jar, the logs should be in ../PATH.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜