You cannot - there is no such console as a console on the server. You need to use the Trace statements and attach the TraceListener .
You can try TextWriterTraceListener . initializeData is the path to where the log file will be written. Note. The user of the application pool identifier will need write permission for this path.
<configuration> <system.diagnostics> <trace autoflush="false" indentsize="4"> <listeners> <add name="myListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="TextWriterOutput.log" /> <remove name="Default" /> </listeners> </trace> </system.diagnostics> </configuration>
source share