{"id":17540,"date":"2015-02-25T12:53:39","date_gmt":"2015-02-25T07:23:39","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=17540"},"modified":"2015-02-25T12:53:39","modified_gmt":"2015-02-25T07:23:39","slug":"log_output-table-vs-file-inside-amazon-rds","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/log_output-table-vs-file-inside-amazon-rds\/","title":{"rendered":"log_output TABLE vs FILE inside Amazon RDS"},"content":{"rendered":"<p>Amazon RDS provides us with three different types of logs :<\/p>\n<h3 style=\"text-align: justify;color: #ff9900\">1) General Logs<\/h3>\n<h3 style=\"text-align: justify;color: #ff9900\">2) Slow Query Logs<\/h3>\n<h3 style=\"text-align: justify;color: #ff9900\">3) Error Logs<\/h3>\n<p>&nbsp;<\/p>\n<p>You can enable these logs by modifying the DB Parameter Group.<\/p>\n<h3 style=\"text-align: justify;color: #ff9900\">1) Enable General Log<\/h3>\n<p>[js]<br \/>\nParameter Name : general_log<br \/>\nValue : set the value to 1. Default is 0.<br \/>\n[\/js]<\/p>\n<h3 style=\"text-align: justify;color: #ff9900\">2) Enable Slowquery Log<\/h3>\n<p>[js]<br \/>\nParameter Name : slow_query_log<br \/>\nValue : set the value to 1. Default is 0.<br \/>\n[\/js]<\/p>\n<p>Once you enable these logs, Amazon RDS starts generating logs.<\/p>\n<p>Amazon RDS defines two output format ( TABLE or FILE )for logs storage :<\/p>\n<p>[js] Parameter : log_output [\/js]<\/p>\n<p>&nbsp;<\/p>\n<h3 style=\"text-align: justify;color: #ff9900\">1) TABLE (default)<\/h3>\n<p><\/p>\n<p>&#8211;&gt; If log_output is set to TABLE, then Amazon RDS generates logs inside <strong>general log\/slow log<\/strong> inside <strong>mysql.general_log<\/strong> and <strong>mysql.slow_log TABLE<\/strong> respectively.<\/p>\n<p>&#8211;&gt; log contents are accessible through SQL commands. e.g<\/p>\n<p>[js]<br \/>\nmysql&gt; SELECT * FROM slow_log ORDER BY query_time DESC;<br \/>\n[\/js]<\/p>\n<p>&#8211;&gt; logs table are not automatically rotated.<\/p>\n<p>&#8211;&gt; Enabling log_output = TABLE increases amount of data written to database which decreases performance.<\/p>\n<p>&#8211;&gt; as the log file grows, we need to manually rotate the logs by calling below commands successively.<\/p>\n<p>&#8211;&gt; you will always receive this warning &#8220;[ <strong>The MySQL general and\/or slow logs of the DB Instance: rds-Instances are consuming a large amount of provisioned storage.<\/strong>]&#8221; under AWS RDS Events section if you use TABLE format log. As it keeps on writing logs to the databases table.<\/p>\n<p>&#8211;&gt; To manually rotate the general\/slowquery log, you will have to execute the below commands.<\/p>\n<p>[js]<br \/>\nmysql&gt; CALL mysql.rds_rotate_slow_log;<br \/>\nmysql&gt; CALL mysql.rds_rotate_general_log;<br \/>\n[\/js]<\/p>\n<p>Note : To remove logs completely and free the disk space, call the above command twice.<\/p>\n<h3 style=\"text-align: justify;color: #ff9900\">2) FILE.<\/h3>\n<p><\/p>\n<p>&#8211;&gt; If log_output is set to FILE, then Amazon RDS writes the logs to the file system.<\/p>\n<p>&#8211;&gt; logs are automatically rotated every hours and logs file older than 24 hours are deleted automatically.<\/p>\n<p>&#8211;&gt; logs can be seen \/ downloaded directly from <strong>Amazon RDS API, Amazon RDS CLI, or AWS SDKs.<\/strong><\/p>\n<p>To Download logs directly from the AWS RDS Console, you have to execute the below API call.<\/p>\n<p>[js]<\/p>\n<p>aws rds download-db-log-file-portion &#8211;db-instance-identifier testing-RDS &#8211;log-file-name slowquery\/mysql-slowquery.log &#8211;output text &gt; file.txt<\/p>\n<p>[\/js]<\/p>\n<p>Note : It&#8217;s recommended to set the Value of Parameter &#8220;log_output&#8221; as FILE for the better performance, as it lowers the overheads of read and write on databases.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Amazon RDS provides us with three different types of logs : 1) General Logs 2) Slow Query Logs 3) Error Logs &nbsp; You can enable these logs by modifying the DB Parameter Group. 1) Enable General Log [js] Parameter Name : general_log Value : set the value to 1. Default is 0. [\/js] 2) Enable [&hellip;]<\/p>\n","protected":false},"author":100,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":82},"categories":[1174],"tags":[288,76,1442,646],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/17540"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/100"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=17540"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/17540\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=17540"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=17540"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=17540"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}