title: log4j / slf4j package-based logging, how to handle frameworks, e.g. spring?
body: <p>Let's say my application consists of several components which are logged separately:</p>
  
  <pre><code>myapp.log
  myapp-foo.log
  myapp-bar.log
  </code></pre>
  
  <p>My classes all define a "standard" java logger:</p>
  
  <pre><code>private static final Logger logger = LogManager.getLogger(ThisClass.class);
  </code></pre>
  
  <p>Logging for components "foo" and "bar" is set up via package-based configuration (each of which logs to it's own logfile) :</p>
  
  <pre><code>&lt;Logger name="com.mycompany.myapp.foo" level="info"&gt;
      &lt;AppenderRef ref="foo"/&gt;
  &lt;/Logger&gt;
  
  &lt;Logger name="com.mycompany.myapp.bar" level="info"&gt;
      &lt;AppenderRef ref="bar"/&gt;
  &lt;/Logger&gt;
  </code></pre>
  
  <p>This works fine, up to the point where we want to see log messages from a framework we use, such as spring, since spring log statements end up in <code>myapp.log</code> - not <code>myapp-foo.log</code> or <code>myapp-bar.log</code>.</p>
  
  <p>It's convenient to have one <code>log4j.xml</code> or <code>log4j2.xml</code> file, but can we use package-based log configuration in this way -  <em>and still have spring log statements logged to the "correct" log file, <code>myapp-foo.log</code> of <code>myapp-bar.log</code></em>?</p>
  
  <p>Or is there a different solution?</p>
  
  <p>Edit: we are using spring 4.0.3.RELEASE and log4j2</p>