<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://programmingexamples.net/w/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://programmingexamples.net/w/index.php?action=history&amp;feed=atom&amp;title=CPP%2FLogging</id>
		<title>CPP/Logging - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://programmingexamples.net/w/index.php?action=history&amp;feed=atom&amp;title=CPP%2FLogging"/>
		<link rel="alternate" type="text/html" href="http://programmingexamples.net/w/index.php?title=CPP/Logging&amp;action=history"/>
		<updated>2026-05-02T09:36:14Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.5</generator>

	<entry>
		<id>http://programmingexamples.net/w/index.php?title=CPP/Logging&amp;diff=81&amp;oldid=prev</id>
		<title>Daviddoria: Created page with '==Logging.cpp== &lt;source lang=&quot;cpp&quot;&gt; #include &lt;iostream&gt; #include &lt;fstream&gt; using namespace std;  void ChangeCoutDestination(); void LogToScreen(); void LogToFile();  int main() {…'</title>
		<link rel="alternate" type="text/html" href="http://programmingexamples.net/w/index.php?title=CPP/Logging&amp;diff=81&amp;oldid=prev"/>
				<updated>2010-06-23T12:35:28Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;#039;==Logging.cpp== &amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt; #include &amp;lt;iostream&amp;gt; #include &amp;lt;fstream&amp;gt; using namespace std;  void ChangeCoutDestination(); void LogToScreen(); void LogToFile();  int main() {…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Logging.cpp==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;fstream&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
&lt;br /&gt;
void ChangeCoutDestination();&lt;br /&gt;
void LogToScreen();&lt;br /&gt;
void LogToFile();&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  //LogToFile();&lt;br /&gt;
  LogToScreen();&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void ChangeCoutDestination()&lt;br /&gt;
{&lt;br /&gt;
  ofstream ofs(&amp;quot;file.out&amp;quot;);&lt;br /&gt;
  cout.rdbuf(ofs.rdbuf());&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Output.&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  ofs.close();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void LogToScreen()&lt;br /&gt;
{&lt;br /&gt;
  clog &amp;lt;&amp;lt; &amp;quot;Logged.&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Test&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void LogToFile()&lt;br /&gt;
{&lt;br /&gt;
  //save the original buffer&lt;br /&gt;
  streambuf *clog_save = clog.rdbuf();&lt;br /&gt;
  ofstream ofs(&amp;quot;file.log&amp;quot;);&lt;br /&gt;
  clog.rdbuf(ofs.rdbuf());&lt;br /&gt;
  clog &amp;lt;&amp;lt; &amp;quot;Logged.&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Test&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  //reset the buffer&lt;br /&gt;
  clog.rdbuf(clog_save);&lt;br /&gt;
  ofs.close();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Daviddoria</name></author>	</entry>

	</feed>