DependencyTrack / DependencyTrack/dependency-track

Executable WAR: Logging configuration improvements

Open
#625 0 comments 1 reaction 0 assignees View on GitHub
enhancement p3
Dominant language
Java
Stars
4.2k
Forks
811
Avg merge
8h 39m
Merged PRs (30d)
237

Description

There are few possible areas of the logging configuration improvements:

### Current Behavior:
1. Log files are written to the **~/.dependency-track/** directory regardless the `alpine.data.directory` property config (description of that property claims that this property affects where logs will be written). That's because in **logback.xml** `fileNamePattern` is set to `${user.home}/.dependency-track/...`

2. We run the WAR as Systemd unit. As a result, all it's console (stdout+stderr) output goes to system log (Systemd journal). If you use the same WAR in the container deployments I can understand this approach, however when running directly I'd prefer very minimal stdout. Property `dependencyTrack.logging.level` doesn't really help as it affects multiple loggers at once and we don't want that.

### Proposed Behavior:
1. I'd lke to be able to change the logging path without having to replace whe logback.xml inside the WAR. It should at least make use of the `alpine.data.directory` property which would be good enough (`${alpine.data.directory}/logs/...` in `fileNamePattern`).

2. I'd like to be able to reduce the amount of logging to STDOUT withouf affecting logging to files. Based on the logged output evaluation something like removing the STDOUT appender from the **org.dependencytrack** logger config would help a lot here. Logback doesn't seem to be able to deal with log levels specified in the appender-ref element (for example log4j2 can do that) which would make it easy to reduce this to WARN here, so this isn't the way to go unfortunately. Some filter would need to be used at the appender level to achieve that.
For example something like the following in the STDOUT appender config might work (based on [JaninoEventEvaluator](http://logback.qos.ch/manual/filters.html#JaninoEventEvaluator), requires Janino library, just a roughly composed untested example, maybe some property could be used to set the level value here as well)
```


logger.startsWith("org.dependencytrack.") && level < WARN

NEUTRAL
DENY

```
Of course you may decide to use another approach.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.