Hi Phung,
I am not an expert in this matter, but after some web surfing I found this,
To rotate logs in a Mendix application without restarting it, you can use an external log rotation tool such as Logrotate. Here's how you can configure Logrotate to rotate your application's log files by date:
Install Logrotate on your server if it is not already installed.
Create a configuration file for your application's log file rotation. For example, you can create a file named /etc/logrotate.d/myapp
with the following content:
/path/to/myapp/logs/*.log { daily missingok rotate 7 compress delaycompress notifempty create 0640 mendix mendix sharedscripts postrotate /usr/bin/killall -HUP m2ee endscript }
bashCopy code
Replace /path/to/myapp/logs
with the path to your application's log directory. The daily
option tells Logrotate to rotate the log file every day. The missingok
option tells Logrotate to not complain if the log file is missing. The rotate
option tells Logrotate to keep 7 rotated log files. The compress
and delaycompress
options tell Logrotate to compress the rotated log files. The notifempty
option tells Logrotate to not rotate the log file if it is empty. The create
option tells Logrotate to create a new log file with the specified permissions and ownership. The sharedscripts
option tells Logrotate to run the postrotate script once for all rotated files, instead of once for each rotated file. The postrotate
script sends a SIGHUP signal to the m2ee
process, which will cause it to reopen the log file.
logrotate -d /etc/logrotate.d/myapp
bashCopy code
This will run Logrotate in debug mode and show you what actions it would take.
bashCopy code
logrotate -f /etc/logrotate.d/myapp
This will force Logrotate to rotate the log file immediately.
Note that this configuration assumes that your application is running as the mendix
user and group. If it is running as a different user and group, you'll need to adjust the create
option
Hope it helps!