[logback-user] Job Logger configuration

Matt Young solid at youngdev.net
Fri Oct 11 03:18:10 CEST 2013


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


OK so I am working on a custom job engine and I am trying to separate my
job logs from the main application logs as well as separating the logs
for each individual job run from each other.  My plan is to
use the sifting log appender to put the logs into a hierarchy on the
filesystem as the
 {job_group}/{job_name}/{instance_id}
I know I can pull multiple values out of the MDC for use in the pattern
layout but I am having trouble using them in the filename.
I am not sure my above approach will work for directory names but
according to the docs it should work at least for the filename.

My second question is how do I keep my job logs out of the main log?

Here is my current config:
<?xml version="1.0" encoding="UTF-8"?>

<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{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread] %C:%L
%msg%n</pattern>
    </encoder>
  </appender>
  <appender name="jobLoggerAppender"
class="ch.qos.logback.classic.sift.SiftingAppender">
             <sift>
            <appender name="FILE-${jobId}"
class="ch.qos.logback.core.FileAppender">
                <file>${jobGroup}-${jobId}.log</file>
                <layout class="ch.qos.logback.classic.PatternLayout">
                    <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level
[%thread] %C:%L %msg%n</pattern>
                </layout>
            </appender>
        </sift>
    </appender>


  <logger name="com.lordofthejars.foo" level="INFO" additivity="false">
   <appender-ref ref="STDOUT" />
  </logger>

  <!-- Strictly speaking, the level attribute is not necessary since -->
  <!-- the level of the root level is set to DEBUG by default.       -->
  <root level="DEBUG">             <appender-ref ref="STDOUT" />

  </root>
  <logger name="jobLogger" level="debug">
      <appender-ref ref="jobLoggerAppender"/>
  </logger>
 </configuration>

- -- 
Cheers,
Matt Young
solid at youngdev.net
http://youngdev.net

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJSV1HSAAoJEO5jycTTPEzc/0IP/Rr48HksJFgSDg2iSUIsOL6X
arJ/VADWDWG+4ydApy+Gw5B5Zx1D8Ds6TQzKB9rSX2lXOJoO/zRb/ObF6eOx8d9t
koVSO7bG9foID/DUm29cGm7ne11yA06EmYyxjJQ0e8TD6ixxIPyiQIOr1cfvRT0/
e3mkrH+xJUByXmRu9elsOzDYk1xqwIRY6I5KcB1g3/2NxOTjG8DL7n3WTcKbea0t
g0QOlFv5jLwsxa5l0SDn2ONtV+QipS/ecvTdnH+bk7FvY5bX0UcEURfQcKiMK9Sl
fozS+AeukrBi4W72iVFYeQxxaYpJyEqRp457yq++wPGbeJP8w0cn7Cke9a8i9M7h
pudRazu6MXF1u9c2kWscCugdpHAcEA+HXS94Ah5RlXkX9VBqKoc2pjrzx+wrZcCh
nAODUWdFx8C654hmjFSD0oUKNaG5WEwJbQaAwFCrOdlB31Teeqw10e3ArcI/D9OL
dnWFXGdD/QKKoCfgMCs3nFhPDmGuMzcBDopR5bxF5DDspoALxiHbLS6eRIXhYH+i
aieeERi4GnJsCRfCVJbqK4qOq2ePuwi8HDptRNTv8HiHmC4uNz51k/VL0cqHpjlw
8ZrSUFAe4h6D7TsrLJ9ehac8J1QlAtycq1MX/4fleWXf2dK53kgNBbPDNBQsV2lZ
X34Ooo+zOV15p7ijQ2en
=mdwF
-----END PGP SIGNATURE-----


More information about the Logback-user mailing list