I would like my app to write logs to an application log file, managed by the built in OS syslog.
Logs appear to be in the var/log/[application] folder. But how to create one that is automated and how to write to it?
Xojo includes the system and debug but neither is appropriate for what I am looking for at the moment; I would be better off having them in separate folders (there are 3 different apps). I tried writing my own logs but they can get large quickly since they are not managed.
Any help would be appreciated!
System.Debuglog gets into journalctl -b
System.Log(LogLevel, mymsg) gets there too!
If you run your application as systemd service, you can simply put this command to read the above calls:
journalctl -u myservice.service
How to you read them without using my app? Normally I use Webmin. I also would like to sort by app, and type (like TRACE, EXCEPTION, WARNING etc). Right now, there are 3 apps and each has it own set of logs. How can I emulate that with the System.log?
How are you planning on distributing your app on Linux?
I use a TGZ file created with the -P (upper case P) option so that the full path is retained. I then put everything where it needs to be on my system and create the TGZ file from those locations (including /var/log/tolisgroup/ with proper permissions of 766). When the user installs using “sudo tar -xzPvf theBundle.tgz”, all of the files are placed where they need to be with owner, group, and permissions intact.
Yes it will be distributed, along with the hardware (Pi based).
Is it possible for you to use a hybrid of my mechanism and preinstall on your Pi’s volume? In other words -
Create a folder on your build test system of /var/log/myApp
Set the permissions to 766
Set up your app to access /var/log/myApp/myApp.log
Prep a master with your environment installed
Make sure the environment is cleaned of any test data
Use “sudo tar -czPvf myMasterBundle.tgz /path1 /path2 /path3 …” to create the installer
When you prep the user’s system, you execute the reverse to install it:
sudo tar -zxPvf myMasterBundle.tgz
With that done, your Pi is ready to eat
That’s essentially what I do now. The problem is, there is no log rotation. They can grow uselessly and outlandishly. So using the OS’s built in log rotation makes a lot of sense. My issue is how to do that AND keep them all separated!
Which log rotator are you using on the Pi? You might be able to fix this by just adding your log file path/name to its conf file.
If you are using logrotate, check out “man logrotate” to see what you need to add to the /etc/logrotate.conf file.