# How to enable general and slow query logging?

**URL:** <https://forums.percona.com/t/how-to-enable-general-and-slow-query-logging/7736>\
**Category:** Other MySQL® Questions\
**Created:** [July 2, 2020, 1:44am UTC](https://forums.percona.com/t/how-to-enable-general-and-slow-query-logging/7736 "2020-07-02T01:44:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![budiantoip](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/budiantoip/32/1352_2.png) [@budiantoip](https://forums.percona.com/u/budiantoip)\
**Post date:** [July 2, 2020, 1:44am UTC](https://forums.percona.com/t/how-to-enable-general-and-slow-query-logging/7736/1 "2020-07-02T01:44:50Z")

</div>

I am about to analyze slow queries, but I’m still new to Percona, can anyone give me a clue on how to enable the general and slow query logging?

---

<div class="post-metadata">

**Author:** ![vaibhav\_upadhyay40](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/vaibhav_upadhyay40/32/9_2.png) [@vaibhav\_upadhyay40](https://forums.percona.com/u/vaibhav_upadhyay40)\
**Post date:** [July 2, 2020, 2:44am UTC](https://forums.percona.com/t/how-to-enable-general-and-slow-query-logging/7736/2 "2020-07-02T02:44:09Z")

</div>

Hi @budiantoip   
To check whether general and slow logs enabled, please use below command:  
MySQL\>show global variables like “general\_log%”;  
  
MySQL\>show global variables like “slow\_que%”;  
  
Also once you enable the slow\_query\_log you also have to check what is long\_query\_time:  
show global variables like “long\_query%”;  
Long\_query\_time: The value represents in seconds, for e.g. if the value is 10, this means any query which takes 10 or more than 10 seconds it will be considered as slow query and further will be logged in to the slow\_query\_log\_file (if&nbsp;slow\_query\_log is ON/enabled).  
  
Hope this helps.

---

<div class="post-metadata">

**Author:** ![budiantoip](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/budiantoip/32/1352_2.png) [@budiantoip](https://forums.percona.com/u/budiantoip)\
**Post date:** [July 2, 2020, 4:16am UTC](https://forums.percona.com/t/how-to-enable-general-and-slow-query-logging/7736/3 "2020-07-02T04:16:30Z")

</div>

Hi @vaibhav_upadhyay40, thank you for your reply, I finally changed the server configuration, by adding these variables to the configuration file :  
slow\_query\_log = 1slow\_query\_log\_file = /var/log/mysql/slow.loglong\_query\_time = 1  
I was finally able to read the slow queries.

---

<div class="post-metadata">

**Author:** ![vaibhav\_upadhyay40](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/vaibhav_upadhyay40/32/9_2.png) [@vaibhav\_upadhyay40](https://forums.percona.com/u/vaibhav_upadhyay40)\
**Post date:** [July 3, 2020, 6:47pm UTC](https://forums.percona.com/t/how-to-enable-general-and-slow-query-logging/7736/4 "2020-07-03T18:47:44Z")

</div>

Happy to know 🙂

---

<div class="post-metadata">

**Author:** ![sreelu](https://avatars.discourse-cdn.com/v4/letter/s/ac91a4/32.png) [@sreelu](https://forums.percona.com/u/sreelu)\
**Post date:** [July 8, 2020, 2:55am UTC](https://forums.percona.com/t/how-to-enable-general-and-slow-query-logging/7736/5 "2020-07-08T02:55:18Z")

</div>

To write&nbsp;general and slow query log&nbsp;entries only to the&nbsp;log **&nbsp;** tables, use --log\_output=TABLE to select tables as the&nbsp;log&nbsp;destination and --general\_log and --slow\_query\_log to&nbsp;enable&nbsp;both&nbsp;logs. For more [visit here](https://mindmajix.com/facets-training).
