Setup log rotation for SG

I’m on Ubuntu 14.04

I tried to follow this documentation about log rotation

My current workflow is to start/stop/restart SG like these commands:
service sync_gateway start|stop|restart
I’d still like to use this workflow after setting up log rotation.

At the moment it seems that there is no log rotation setup as there is only one sync_gateway_error.log file which is GBs in size. I don’t know where to add this config:
/home/sync_gateway/logs/* { daily rotate 1 size 10M delaycompress compress notifempty missingok postrotate /usr/bin/pkill -HUP sync_gateway > /dev/null endscript }
Would I add this to the sync_gateway.json file? Mine look similar to this:

{ "interface": ":4984", "adminInterface": ":4985", "log": [ "CRUD", "CRUD+", "HTTP", "HTTP+", "Access", "Cache", "Changes", "Changes+" ], "databases": { "database-name": { "server": "http://localhost:8091", "bucket": "bucket-name", "allowEmptyPassword" : true, "users": { "GUEST": { "disabled": true, "admin_channels": [ "*" ] } }, "sync":function(doc, oldDoc){
if(oldDoc){requireAccess(oldDoc.channels);}
channel (doc.channels) }} } }

So my two questions are:

  1. Where do I need to put the config?
  2. What needs to change so that I can use my current workflow?

@benjamin_glatzeder

Typically logrotate application configurations go in `/etc/logrotate.d’

Add this top level property to your config "logFilePath":"<PATH_TO_ROTATED_LOG_FILE>"

I think this can still point to /home/sync_gateway/logs/sync_gateway_error.log

This is what I did:

I created a file in /etc/logrotate.d named sync_gateway and added these lines to it
/home/sync_gateway/logs/* { daily rotate 1 size 10M delaycompress compress notifempty missingok postrotate /usr/bin/pkill -HUP sync_gateway > /dev/null endscript }

The start of my SG config looks like this:
{ "logFilePath": "/home/sync_gateway/logs/sync_gateway_error.log" "interface": ":4984", "adminInterface": ":4985", ...

Then I restarted SG service sync_gateway restart. I synced a few documents and changes were written to the file.
tail -100 sync_gateway_error.log
As far as I understand the logrotate config it should create a new log file as soon as the file is 10Mb in size. Could I somehow do some other checks or tests. Also I named the logrotate file sync_gateway. I’m unsure if I need to reference this anywhere or if it should have a different name.