Layer7 API Management

Expand all | Collapse all

How to make separate log files for each API by using syslog

  • 1.  How to make separate log files for each API by using syslog

    Posted Apr 20, 2017 11:01 PM

    Hello All,

     

           I want to take the logs of specific APIs or Webservices separately. I have done the setup by creating syslog mechanism but every API log storing in /va/log/messages.

     

    But i don't want to write the logs into messages, I want each API write the logs into separate log file which i mention Like

     

    Service1 log has to write in /var/log/1.log

    Service2 log has to write in /var/log/2.log

    ------------------

    ------------------ 

    Service10 log has to write in /var/log/10.log        

     

    Hope my requirement is clear. Please suggest me how to achieve this.

     

    Regards

    Rajasekhar



  • 2.  Re: How to make separate log files for each API by using syslog
    Best Answer

    Broadcom Employee
    Posted Apr 21, 2017 04:53 AM

    Hello Rajasekhar,

     

    You can select in the Log Sink Properties , the Add button to select a filter for the log file.

    In this section you can select the services from the Filter type , this will display all known services and you can select the services that you wish to have in the log file.

     

    I hope this helps , let us know if you need any further info.

     

    Thanks & Regards,

    Clive



  • 3.  Re: How to make separate log files for each API by using syslog

    Posted Apr 21, 2017 06:16 AM

    Thank you Smith.

    That way i can select the services which i want to write the logs into /var/log/messages.

    If i create 3 separate syslogs. All will be stored into /var/log/messages only.

     

    I want each syslog to be write in separate log file.

     

    How can i do this?

     

    Regards

    Rajasekhar



  • 4.  Re: How to make separate log files for each API by using syslog

    Broadcom Employee
    Posted Apr 21, 2017 07:06 AM

    Hello Rajasekhar,

     

    When defining the Log Sink you can specify to have it write to a file.

    By default the file will be created in the directory - /opt/SecureSpan/Gateway/node/default/var/logs

    The file will then be named in default as follows :  {1}_{2}_{3}.log (log1_0_0.log)

    The following cluster wide property controls how the log file name is formated :

    log.filenameTemplate

    Template of the file name pattern for log file names.

    Default: {1}_{2}_{3}.log

    Where:

    {1} = sink name
    {2} = generation number to distinguish rotated logs
    {3} = unique number to resolve conflicts

     

    As you can see from my example I set my Sink Log name to "log1".

     

    Thanks & Regards,

    Clive

     



  • 5.  Re: How to make separate log files for each API by using syslog

    Posted Apr 23, 2017 09:51 PM

    Sorry Smith...Little bit of confusion.

     

    Every Webservice/API log writes into /opt/SecureSpan/Gateway/node/default/var/logs/ssg.log, ssg1.log......

    As you know we have 2 mechanism to set the log sinks i.e., File based and Syslog

     

    If i am not wrong we will create Syslog because of wants to place the logs in separate server.

    What i want here, only some set of webservices logs which i mention in syslog filter.

    But as per your information all logs will be stored in ssg logs which i dont want to be.

     

    Please guide me to find out the solution.

     

    Regards

    Rajasekhar 

     



  • 6.  Re: How to make separate log files for each API by using syslog

    Posted Apr 23, 2017 09:59 PM

    I am sorry smith. Please clarify me below.

     

    When defining the Log Sink you can specify to have it write to a file

    Where i can specify the file.Can you please provide me some screen shot of configuration. I am unable to find out where i can set the path of that.



  • 7.  Re: How to make separate log files for each API by using syslog

    Broadcom Employee
    Posted Apr 24, 2017 04:14 AM

    Hello Rajasekhar,

     

    You can setup the Log sink to write to the syslog but you would need to have seperate syslogs for each service.

    My suggestion is to setup that the service entries are sent to a local file.

    I have created a log sink called "myservice" , as you can see from the following screenshots the file gets created with the name of the Log sink.

    Log sink setup :

     

    The directory listing where the file is created :

     

    As you can see the file is created myservice_0_0.log file , which corresponds to the Log sink name "myservice".

     

    I hope this answers your questions.

     

    Thanks & Regards,

    Clive



  • 8.  Re: How to make separate log files for each API by using syslog

    Posted Apr 24, 2017 06:01 AM

    Exactly..Thank you so much..some how i got my answer.

     

    But its writing in to common location /opt/Secure/Gateway/node/default/var/logs and that too you are using File as type. I want it to be in Syslog because of the logs should be write into other server not at Gateway server.

     

    Is there any possibility to write the API based logs into some other server instead of Gateway server by using Syslog mechanism?

     

    Regards

    Rajasekhar 



  • 9.  Re: How to make separate log files for each API by using syslog

    Broadcom Employee
    Posted Apr 24, 2017 07:21 AM

    Hello Rajasekhar,

     

    You can configure each sink to send to the remote syslog , but you will need to configure the syslog to have different rulesets for each port to separate the destination files.

    The following link supplies information for how to configure syslog to write to different files based on the port receiving the messages :

    Multiple Rulesets in rsyslog — rsyslog 8.27.0.master documentation 

     

    This syslog configuration is outside of the API Gateway and you may need to discuss with your sysadmins/net-Admins for the ports being used and configuration changes.

     

    Similar to how the files configuration was done above you can do the same with a syslog destination , you would need to select different ports for each services logs.

     

    Thanks & Regards,

    Clive

    http://www.rsyslog.com/doc/master/concepts/multi_ruleset.html#split-local-and-remote-logging-for-three-different-ports



  • 10.  Re: How to make separate log files for each API by using syslog

    Posted Apr 24, 2017 09:52 PM

    Thank you so much CLIVE.

     

    It helps alot. I will try and reply back to this.



  • 11.  Re: How to make separate log files for each API by using syslog

    Posted Apr 24, 2017 10:05 PM

    Hi CLIVE,

     

           How many Syslogs can i create?

     

    Regards

    Rajasekhar



  • 12.  Re: How to make separate log files for each API by using syslog

    Broadcom Employee
    Posted Apr 25, 2017 09:39 AM

    Hello Rajasekhar,

     

    There is no limit , but you need to realise that the more you have the more of a performance hit you will have due to the extra processing and network activity.

     

    Thanks & Regards,

    Clive



  • 13.  Re: How to make separate log files for each API by using syslog

    Posted Apr 25, 2017 09:26 PM

    Yes, I understood.

    Thank you so much for your valuable information.