MySQL 5.6 and Enable Slow Query Logging

The commented out examples in the default configuration file (/etc/mysql/my.cnf) that comes with my MySQL 5.6 when installed through the Ubuntu PPA is incorrect. This tutorial will show you the settings you need to make in order to enable slow query logging.

# This tells mysql that you do want to use slow query logging.

# Define where the log file should be
slow_query_log_file = /var/log/mysql/slow_queries.log

# Set this to the number of seconds a query must take to be considered "slow"
long_query_time = 1

# Also, if you want to log all queries that don't use indexes:

After making any changes to the my.cnf file, don’t forget to restart the service in order for them to take effect:

sudo service mysql restart

Please note: If you notice the mysql-slow.log file logging every query then remove the line "log-queries-not-using-indexes" from your /etc/my.cnf file and restart mysql. It should the load only the slow queries

Export Windows Event logs with PowerShell

powershell windows server

powershell windows server

1. Create a text file

2. Paste the following command in:

Get-Eventlog -LogName application -EntryType Error,Warning | Export-csv application_logs.csv | Get-Eventlog -LogName System -EntryType Error,Warning | Export-Clixml system_logs.csv

3. Save this file as windows_event_logs_dumper.ps1

When this script is ran, it pulls all of the application and system event logs, where the -EntryType is warning or error.

Going a step further, you could write a kscript that runs this script, then do a step to “Upload a file” which will upload those logs to the computer inventory for each machine the script is ran on.