ArtifactorySystemdLogging

Note: You are viewing an old revision of this page. View the current version.

Logging to Syslog or Systemd with Artifactory

By default, Artifactory sends it's log messages to <artifactory home>/logs/artifactory.log. This is fine, but it's handy to also send the log files to the system log. This is expecially true if you use a modern linux that runs systemd, as systemd provides the journalctl utility to display and filter logs.

Jfrog has this page about logging to syslog, and the information there is generally correct. However, it's not complete. The following is my complete guide to sending artifactory logs to syslog.

Syslog Listener

Artifactory uses the java logging tool logback, which supports sending logs to syslog. That should work fine, but there's one annoying catch: logback does not support unix sockets. It only supports udp sockets. That means you have to have some sort of network listener set up to receive syslog messages, even when your syslog is on the same server.

Fortunately, you can use netcat as a minimal listener and forwarder. Here are the steps:

1. Set up Systemd with netcat

Write a script to run netcat and forward the results to systemd.

I found some excellent info about how to both set up the listener and do some post-processing to clean up the logs. That example got a little more complicated than I wanted, so I modified it to run as a bash script:

        ExecStart = "/bin/sh -c 'socat -u UDP-RECV:514 STDOUT | ${package}/artifactory-pro/bin/syslog-formatter.sh'";
#!/usr/bin/env bash

# Pretty up the logback output by removing the date, time, etc. and
# then send it to systemd.  Otherwise a lot of info is duplicated.

sed -u -e "s/^ *<.* \[/[/" | systemd-cat -t artifactory

2. Configure systemd to automatically run the script to set up the listener on boot.

Artifactory Configuration



Our Founder
ToolboxClick to hide/show
RecentChanges Click to hide/show