As a DBA, it is generally a good idea to log all your activity when working on Unix/Linux servers. Logging provides an audit of changes that you have made to a system as well as being a valuable resource for notes and documentation. This article describes how to log all PuTTY sessions and how to automatically maintain the resulting log files in a logical directory structure based on date as follows:
First off, you need to enable logging as the default. Launch PuTTY and navigate to the Logging section and configure the options as shown. Unfortunately, we can't specify the directory structure within PuTTY as it won't automatically create directories if they don't already exist.
Finally, navigate back to the Sessions list, highlight "Default Settings" and click Save. Annoyingly, if you have any saved sessions already, you will need to load each one, set the logging options and save it again (as there isn't any way to change logging globally).
At this point, all your PuTTY sessions will be logged to a single directory. However, after you've logged a few hundred sessions you'll wish there was a nice easy way to keep the files organised. The easiest way is to create a BAT file with the following code, which you can either put in your startup folder or schedule to run (via the windows scheduler) on a regular basis:
@echo off c: cd C:\logs for %%a in (*.*) do ( for /f "tokens=1,2,3 delims=/ " %%x in ("%%~ta") do md %%z\%%y\%%x&move "%%a" "%%z\%%y\%%x" )