#define LOG using System; using System.IO; using System.Diagnostics; class Starter { static void Main() { LogInfo(new StreamWriter(@"c:\logfile.txt")); } [Conditional("LOG")] private static void LogInfo(StreamWriter sr) { // write information to log file } }