Search code examples
logbacknexusnexus3

How to override logback config in Sonatype Nexus 3?


I'm running Sonatype Nexus 3.15.0-01 and am a little stumped about how to override the default logback configs.

I created a file called 'logback-overrides.xml' in the 'nexus-data/etc/logback' folder containing the following:

    <?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <appender name="FILE" class="ch.qos.logback.core.FileAppender">
    <file>/nexus-data/log/myApp.log</file>
    <encoder>
      <pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n</pattern>
    </encoder>
  </appender>


  <root level="debug">
    <appender-ref ref="FILE" />
  </root>
</configuration>

This is essentially just a simple bit of config that should cause logs to be written to '/nexus-data/log/myApp.log'. I restarted the server after adding this file, to confirm it would pick up the new configs.

However, when I check for that file, it's not present. What am I missing here?


Solution

  • I posted this same question on the Sonatype forums here. To sum up the answer I got there, it isn't possible to override the default logback config this way.

    Possible workarounds are:

    1. Create your own logback.xml file and build your own Docker image that extends Sonatype’s official image.
    2. Create a volume mount for /opt/sonatype/nexus/etc/logback and customize the logback.xml on your host machine.