Redirect Service Logs to File

Greetings Toradex Team!

I’m having some trouble to view an application logs (printf) when using this process as a service. I am basically trying to run this code:

#include <stdio.h>
#include <unistd.h>

int main(int argc, char *argv[]) {

    while (1) {
        printf("hello world!\r\n");
        sleep(5);
    }
    return 0;
}

Also, I created a systemd service with this service file:

[Unit]
Description=Demo service
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
RestartSec=1
User=root
StandardOutput=file:/home/root/log1.log
StandardError=file:/home/root/log2.log
SyslogIdentifier=demo_service
WorkingDirectory=/home/root
ExecStart=/home/root/theDemo

[Install]
WantedBy=multi-user.target

After starting the service, I can see that the it created the log1.log file on my home directory. However, no matter what I do the file is always empty. I have also tried to export the logs to syslog, but I have zero experience with that and got nowhere…