How to configure log rotation on apigee edge components wherever configuration not present?

Not applicable

I want to rotate all the logs in apigee edge components. I could see many of the services doesn't have logrotation feature by default. In my working environment, there is no log rotation config for below services.

edge-ui, zookeeper, openLDAP, qpidd, qpid-server, postgress, etc..

I tried to create /opt/apigee/<apigee service>/source/conf/logback.xml wherever it doesn't exist, and restarted the service. No impact with this.

Also I tried creating /opt/apigee/<apigee service>/source/conf/logrotate.conf and restarted the service. Still no impact.

Please help me.

1 5 4,627
5 REPLIES 5

@SURESHT ,

  1. For ZooKeeper, you can refer to the section “Log File Maintenance” to setup log rotation here.
  2. Similarly For Cassandra, you can refer to the section “Log File Maintenance” to setup log rotation here.
  3. For Edge UI and Management Server components, you can use rolling file appender to rotate the files.
  4. For Nginx Router, we use operating system's log rotate facility and cron job for rotating logs.
    • Check the contents of /opt/apigee/edge-router/conf/apigee-nginx-logrotate.conf file. It should be something like this:
      /opt/apigee/var/log/edge-router/nginx/*log {
      missingok
      rotate 720
      compress
      delaycompress
      notifempty
      nocreate
      sharedscripts
      postrotate
      [ -f /opt/nginx/logs/nginx.pid ] && kill -USR1 `cat /opt/nginx/logs/nginx.pid`
      endscript
      }
      		
    • Ensure the below cron job is setup as follows:
      0 * * * * nice -n 19 ionice -c3 /usr/sbin/logrotate -f /opt/apigee/edge-router/conf/apigee-nginx-logrotate.conf
      		

Note: I have provided the links for latest (4.17.09) Private Cloud docs for points #1 and #2. If you are on a slightly older revision, then please refer to docs of specific release under "Edge Private Cloud" from here.

Hi @AMAR DEVEGOWDA,

Can you tell me what token I can use to configure the settings for nginx? I wish to add "daily" to the above config. I found the following in `/opt/apigee/edge-router/token/default.properties`, but it does not tell me what token to use for `daily`

Thanks!

conf_apigee-nginx-logrotate_logs=/var/log/apigee/nginx/*log
conf_apigee-nginx-logrotate_rotate=720
conf_apigee-nginx-logrotate_compress=compress
conf_apigee-nginx-logrotate_compress_type=delaycompress

@Kashmira Patel

Were you able to figure out the property name for "daily" rotation of nginx logs? We are also trying to achieve the same thing.Access logs in nginx directory are around 400 GB for us.

If there was any other way you were able to achieve nginx log rotation, let me know. It would be of great help to us.

Hi Amar,

I see the link you mentioned for Cassandra and Zookeeper has instructions for configuring log rotation on size basis. Our requirement is to change the log rotation to Daily basis and retain the logs for certain duration. How can we configure it?

For other components, we have log back.xml file and it has configuration(timeBasedFileNamingAndTriggeringPolicy) to rotate after reaching certain size or daily. Will the rotation happen only on daily basis is we remove timeBasedFileNamingAndTriggeringPolicy?

Also, is the component restart required every the logs are rotated using log4j or logback.xml configurations?

Appreciate your help!!

@AMAR DEVEGOWDA

We are using Edge 4.19.01 on private cloud and followed the above mentioned steps. But we do NOT see logs being rotated.

In directory "/opt/apigee/var/log/edge-router/nginx", we only see one access log of router with format:

<orgName>~<envName>.9001_access_log

Following are the steps that we are following:

Step 1. Open /opt/apigee/edge-router/conf/apigee-nginx-logrotate.conf
It should have the following content:

/opt/apigee/var/log/edge-router/nginx/*log {

missingok
rotate 720
compress
delaycompress
notifempty
nocreate
sharedscripts
postrotate
/opt/apigee/edge-gateway/bin/issue_sigusr1.sh

endscript
}

Step 2. Replaced the line
/opt/apigee/edge-gateway/bin/issue_sigusr1.sh
with
[ -f /opt/nginx/logs/nginx.pid ] && kill -USR1 'cat /opt/nginx/logs/nginx.pid'

Step 3. Open cron table using following command:

crontab -e

Step 4. Add the following line to it (this will rotate log every 24 hours)

0 * * * * nice -n 19 ionice -c3 /usr/sbin/logrotate -f /opt/apigee/edge-router/conf/apigee-nginx-logrotate.conf

Step 5. Stop crond, using
service crond stop

Step 6. Start crond using
service crond start

Instead of expression, "0 * * * *", we used "* * * * *", to check if the logs are rotated every minute or not (for testing purpose only)

Are we missing anything?