1

I have a systemd service. No logs appear from it despite my best efforts. This is the service file:

[Unit]
Description=Load Balancer

[Service]
WorkingDirectory=/home/lb
ExecStart=/usr/lib/jvm/jdk-20/bin/java --enable-preview -jar /home/lb/app.jar
User=lb
Type=simple
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target

I've also tried adding

StandardOutput=journal
StandardError=journal

Which did nothing. There are also no messages in /var/log/messages. The disk is not full:

# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            5.9G     0  5.9G   0% /dev
tmpfs           1.2G  624K  1.2G   1% /run
/dev/sda3       293G  3.3G  275G   2% /
tmpfs           5.9G     0  5.9G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
/dev/sda2       2.0G   84M  1.8G   5% /boot
tmpfs           1.2G     0  1.2G   0% /run/user/997

journactl shows nothings:

# journalctl --user -u lb
No journal files were found.
-- No entries --

# journalctl -u lb
-- Journal begins at Sat 2023-05-13 12:59:37 CEST, ends at Sat 2023-05-13 13:46:23 CEST. --
May 13 12:59:59 myserver systemd[1]: lb.service: Main process exited, code=exited, status=143/n/a
May 13 12:59:59 myserver systemd[1]: lb.service: Failed with result 'exit-code'.
May 13 12:59:59 myserver systemd[1]: lb.service: Consumed 3.067s CPU time.

Those failed messages are the only thing I see. They happen when I restart the service.

Just to be on the safe side I rewrote the code to do nothing other than printing some logs:

# /usr/lib/jvm/jdk-20/bin/java -jar app.jar
[LoadBalancer] [2023-05-13 13:51:22] [INFO] Hello, world!
[LoadBalancer] [2023-05-13 13:51:22] [ERROR] Second message is an error

I've run systemctl daemon-reload multiple times. Stuff is running:

# ps auxf
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root           1  0.0  0.0 167072 11868 ?        Ss    2022  67:48 /lib/systemd/systemd --system --deserialize 22
root     3286623  0.0  0.0 220800  5252 ?        Ssl  Mar26   7:56 /usr/sbin/rsyslogd -n -iNONE
systemd+ 2751434  0.0  0.0  88440  6168 ?        Ssl  Apr30   0:04 /lib/systemd/systemd-timesyncd
root     2751463  0.0  0.0  21188  4824 ?        Ss   Apr30   0:02 /lib/systemd/systemd-udevd
root     2814177  0.0  0.0  48316  9240 ?        Ss   12:57   0:00 /lib/systemd/systemd-journald

I need to see my logs. Thanks for any help.

EDIT: full output from service lb status (using real code as opposed to the logging statements. Real code prints a started message):

# service lb status
● lb.service - Load Balancer
     Loaded: loaded (/etc/systemd/system/lb.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2023-05-13 17:13:03 CEST; 4s ago
   Main PID: 19711 (java)
      Tasks: 34 (limit: 14334)
     Memory: 75.2M
        CPU: 2.907s
     CGroup: /system.slice/lb.service
             └─19711 /usr/lib/jvm/jdk-20/bin/java --enable-preview -jar /home/lb/app.jar
jurgen
  • 111
  • 2
  • 1
    What does `service status` give you? – Brian May 13 '23 at 14:56
  • 1
    @Brian depends on how I write the code. When I make the app print two messages and die it will say "Active: inactive (dead)". Makes sense because the service never keeps running. If I use the code I really want, it will say: "Active: active (running)". No logs in either case. To be entirely sure I checked to see if my deploy mechanism worked by extracting the version number from app.jar. It definitely is running the version I give it. – jurgen May 13 '23 at 15:15
  • 1
    Try this: [write to journal](https://unix.stackexchange.com/questions/233749/script-cant-write-to-systemd-journal). It's got a lot of good stuff in it. – Brian May 13 '23 at 21:21
  • @Brian I tried the commands at the link you gave me but nothing comes out of the log. It remains empty. – jurgen May 14 '23 at 09:31

1 Answers1

0

I gave up trying to fix it. Reinstalled the entire server. Problem went away.

jurgen
  • 111
  • 2