How to override logback config in Nexus 3?

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

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

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

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

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?

Unfortunately, only certain files in /nexus-data/etc override the default config files. At this time, the best way to customize the logging is to change logback.xml directly.

Guessing that you’re running with the docker image, you have 2 options:

  1. (recommended) create your own logback.xml, store in your source code repo, and build your own docker image based from Sonatype’s official image
  2. Create a volume mount for /opt/sonatype/nexus/etc/logback and customize the logback.xml on your host machine.

For those not running Nexus 3.x with Docker, the logback files are stored in $INSTALL_DIR/nexus-3.15.0-01/etc/logback. NOTE: when upgrading, you will need to manually copy the changes forward to the new version folder.

As noted on Rolling policy for nexus.log not working, Nexus 2 worked a bit differently. The logback files were stored in the sonatype-work folder. It would be more convenient if the same were true in Nexus 3. I have created an improvement ticket to track the request:

1 Like

Thanks, @mworthington! Very helpful. Ultimately, we want to have JSON logging so we can use Kibana, so building a container from source might be the way to go, since we’ll likely need to have extra dependencies for the Jackson logger.

Glad to hear. Keep us posted on your progress, we’re always excited to see and promote the cool things that our users are doing with Nexus!

Also, I see log analytics being done more often on request.log rather than nexus.log. The request.log is the standard web log format where you can track the artifact upload and download HTTP result code, request size, and elapsed time. Typically, this information is more useful when trying to measure usage and performance of your repo. You can see the formatting in the logback-access.xml.