Skip to main content

Logging

Logging and the log viewer are available to those with the nx-all privilege under AdministrationSupportLogging. Here, you can configure the level of logging for Nexus Repository and all plugins as well as inspect the current nexus, audit, cluster, and task logs.

Logging and Configuring Loggers

When upgrading Nexus Repository, keep in mind that some loggers change between versions, so if you rely on specific loggers, you might have to reconfigure them.

The Logging feature view allows you to manage pre-configured loggers and create new ones.

Logging view with table of default loggers

The loggers configured in the user interface are persisted differently based on your setup.

  • In standard installations, loggers are stored in $data-dir/etc/logback/logback-overrides.xml, overriding levels set in $install-dir/etc/logback/logback.xml and other logback-* files. If you need to edit a logging level in those files, edit the overrides file. This will give you access to edit the configuration in the user interface at a later stage and also ensure that the values you configure take precedence.

  • For high-availability (HA) environments, logger configurations are stored in the logging_overrides table for cluster-wide consistency.

Creating a Logger

  1. From the Logging view, select the Create Logger button.

  2. Provide the logger's name in the Logger Name field.

    1. A logger's name typically corresponds to the Java package name used in the source code. Depending on your needs, you can inspect the source of Nexus Repository and its plugins to determine the related loggers.

  3. Select the desired Logger Level.

  4. Select Save.

Modifying a Logger's Logging Level

You can modify the log level for a configured logger by clicking on the row for the logger you wish to modify. This will bring you to a form where you can adjust the logging level using a Logger Level drop-down menu. Select the logging level you wish to use and then press the Update button to apply the change.

Warning

Logger levels are already set at optimal levels for normal operation. Setting loggers to more verbose levels may cause performance issues and any changes you make will take effect immediately. As a best practice, only adjust loggers to diagnose a specific problem and adjust them back to default levels after diagnosing that specific problem.

You can reset all default loggers to their default level by selecting the Reset to Default Levels button.

Note

Opting to reset all loggers to default levels will also delete custom loggers without the underlying default logger configuration.

Logging Levels

The ROOT logger level controls how verbose the logging is in general. If set to DEBUG, logging will be very verbose, printing all log messages including debugging statements. If set to ERROR, logging will be far less verbose, only printing out a log statement if Nexus Repository encounters an error. INFO represents an intermediate amount of logging.

The following table describes the different logging levels.

Logging Level

Description

Trace

This is the most detailed and verbose level of logging; it details every step of an event's code execution.

Debug

This is the second-most detailed and verbose level of logging. It provides granular information to use for debugging and is too verbose for everyday use.

Info

This level of logging provides information about events (e.g., an application entering a certain state, a user requesting authorization). This level is purely informative and can be ignored during normal operations.

Warn

This level indicates that something unexpected occurred in the application, but the primary features continue to operate. It does not mean that the application failed, but it does indicate an issue that could disrupt one of the processes.

Error

This level indicates that the application has encountered an issue preventing proper functionality.

Deleting a Logger

Use the Reset to default levels button to remove all custom loggers and reset all default loggers to their default level.

The Log Viewer is not available when using a High Availability deployment option.

Commonly Adjusted Loggers by Feature Area

Nexus Repository default logger levels are intended to be verbose enough to help diagnose problems should you encounter them but quiet enough to not create overly large log files.

You can increase default log output verbosity when you need to gather more information about a problem or activity. In some cases, making a logger less verbose is justified to avoid spamming the application log with noisy messages.

Below are some of the loggers commonly adjusted by feature area. This is not a complete list and not all loggers are available in all versions of Nexus Repository.

Warning

Logger levels are already set at optimal levels for normal operation. Setting loggers to more verbose levels may cause performance issues. As a best practice, only adjust loggers to diagnose a specific problem and adjust them back to default levels after diagnosing that specific problem.

LDAP

Diagnose LDAP Queries and LDAP Server Connection Stack Traces by setting logger org.sonatype.nexus.ldap to DEBUG.

NuGet Repository Format

Set logger com.sonatype.nexus.repository.nuget to DEBUG to diagnose NuGet issues.

Webhooks

Diagnose outbound webhook payloads by setting org.sonatype.nexus.internal.webhooks to DEBUG.

Click to expand example log entries...

Example Log Entries

2016-12-14 17:09:43,902+0000 DEBUG [event-1-thread-2] admin org.sonatype.nexus.internal.webhooks.WebhookServiceImpl - Sending webhook request: WebhookRequest{id='9d80527e-8f7d-455a-a86b-191e9ac7ab9e', webhook=rm:repository:component, payload=org.sonatype.nexus.repository.webhooks.RepositoryComponentWebhook$RepositoryComponentWebhookPayload@2a89735b, url=http://requestb.in/abcd}
2016-12-14 17:09:44,420+0000 DEBUG [event-1-thread-2] admin org.sonatype.nexus.internal.webhooks.WebhookServiceImpl - Sending POST request: POST http://requestb.in/abcd HTTP/1.1
2016-12-14 17:09:44,736+0000 DEBUG [event-1-thread-3] admin org.sonatype.nexus.internal.webhooks.WebhookServiceImpl - Sending webhook request: WebhookRequest{id='29608664-b00b-4e1a-af3d-d0ced495fd57', webhook=rm:repository:component, payload=org.sonatype.nexus.repository.webhooks.RepositoryComponentWebhook$RepositoryComponentWebhookPayload@9ef9b8, url=http://requestb.in/abcd}
2016-12-14 17:09:44,760+0000 DEBUG [event-1-thread-3] admin org.sonatype.nexus.internal.webhooks.WebhookServiceImpl - Sending POST request: POST http://requestb.in/abcd HTTP/1.1
2016-12-14 17:09:44,765+0000 DEBUG [event-1-thread-2] admin org.sonatype.nexus.internal.webhooks.WebhookServiceImpl - Response status: HTTP/1.1 200 OK
2016-12-14 17:09:44,996+0000 DEBUG [event-1-thread-3] admin org.sonatype.nexus.internal.webhooks.WebhookServiceImpl - Response status: HTTP/1.1 200 OK

When there is an error in posting to the webhook url, then you will see an error like the following:

2016-12-14 16:40:34,567+0000 ERROR [event-1-thread-16] admin org.sonatype.nexus.internal.webhooks.WebhookServiceImpl - Failed to send webhook request: WebhookRequest{id='071b719e-683d-4fb4-a031-12e292ed4ec0', webhook=rm:repository:component, payload=org.sonatype.nexus.repository.webhooks.RepositoryComponentWebhook$RepositoryComponentWebhookPayload@76beefa6, url=http://requestb.in/abcd} org.apache.http.client.HttpResponseException: Not found

User Interface

Diagnose UI search inbound JSON payloads by setting logger org.sonatype.nexus.coreui.SearchComponent to DEBUG.

SAML

Log SAML-related activity by setting loggers com.sonatype.nexus.saml and org.keycloak.saml to DEBUG.

Log Viewer

The Log Viewer is not available when using a High Availability deployment option.

Once logging is configured as desired, you can view and download logs via the user interface in the Logs page, which is available under AdministrationSupportLogs.

114983296.png

A table on this screen contains available nexus, audit, cluster, and task logs. Select a specific log file to view its contents. The image below shows an example nexus.log file displayed in the user interface.

Screen showing a sample nexus.log file displayed in the user interface. Marker to insert log field and insert button are available. Refresh Rate drop-down menu is set to Manual. Size is set to Last 25KB. Download button available as well.

Here, you can set the rate at which the log refreshes by selecting an option from the Refresh Rate drop-down menu. Available options include Manual, Every 20 Seconds, Every Minute, Every 2 Minutes, or Every 5 Minutes. You can manually refresh by selecting the refresh icon (two arrows in a circle) in the top menu.

You can also use the Size drop-down menu to opt whether to display the last 25KB, 50KB, or 100KB.

In nexus.log, you can also add a custom text string into the log in order to create reference points in the log file for analysis. In the Marker to insert into the log text box, type the text you wish to insert; then, select the Insert button. This will insert the text at the bottom of the log file. The text will be surrounded by asterisks (*) to make it easy to find. If you do not insert any of your own custom text in the text box, the button will insert the word "MARK" by default.

Finally, you can download a copy of the logs from the server to your machine by pressing the Download button.