Index: XIOS/branchs/xios-1.0/src/client.cpp
===================================================================
--- XIOS/branchs/xios-1.0/src/client.cpp	(revision 547)
+++ XIOS/branchs/xios-1.0/src/client.cpp	(revision 548)
@@ -21,4 +21,5 @@
     int CClient::rank = INVALID_RANK;
     StdOFStream CClient::m_infoStream;
+    StdOFStream CClient::m_errorStream;
 
     void CClient::initialize(const string& codeId,MPI_Comm& localComm,MPI_Comm& returnComm)
@@ -233,45 +234,83 @@
    }
 
-     /*!
-      * \brief Open file stream to write in
-      *   Opening a file stream with a specific file name suffix-client+rank
-      * \param [in] protype file name
-     */
-     void CClient::openInfoStream(const StdString& fileName)
-     {
-       std::filebuf* fb = m_infoStream.rdbuf();
-       StdStringStream fileNameClient;
-       int numDigit = 0;
-       int size = 0;
-       MPI_Comm_size(CXios::globalComm, &size);
-       while (size)
-       {
-         size /= 10;
-         ++numDigit;
-       }
-
-       fileNameClient << fileName << "_" << std::setfill('0') << std::setw(numDigit) << getRank() << ".out";
-       fb->open(fileNameClient.str().c_str(), std::ios::out);
-       if (!fb->is_open())
-       ERROR("void CClient::openInfoStream(const StdString& fileName)",
-            <<endl<< "Can not open <"<<fileNameClient<<"> file to write" );
-
-       info.write2File(fb);
-       report.write2File(fb);
-     }
-
-     //! Write out to standard output
-     void CClient::openInfoStream()
-     {
-       info.write2StdOut();
-       report.write2StdOut();
-     }
-
-     //! Close file if it opens
-     void CClient::closeInfoStream()
-     {
-       if (m_infoStream.is_open()) m_infoStream.close();
-     }
-
-
+    /*!
+    * Open a file specified by a suffix and an extension and use it for the given file buffer.
+    * The file name will be suffix+rank+extension.
+    * 
+    * \param fileName[in] protype file name
+    * \param ext [in] extension of the file
+    * \param fb [in/out] the file buffer
+    */
+    void CClient::openStream(const StdString& fileName, const StdString& ext, std::filebuf* fb)
+    {
+      StdStringStream fileNameClient;
+      int numDigit = 0;
+      int size = 0;
+      MPI_Comm_size(CXios::globalComm, &size);
+      while (size)
+      {
+        size /= 10;
+        ++numDigit;
+      }
+
+      fileNameClient << fileName << "_" << std::setfill('0') << std::setw(numDigit) << getRank() << ext;
+      fb->open(fileNameClient.str().c_str(), std::ios::out);
+      if (!fb->is_open())
+        ERROR("void CClient::openStream(const StdString& fileName, const StdString& ext, std::filebuf* fb)",
+              << std::endl << "Can not open <" << fileNameClient << "> file to write the client log(s).");
+    }
+
+    /*!
+    * \brief Open a file stream to write the info logs
+    * Open a file stream with a specific file name suffix+rank
+    * to write the info logs.
+    * \param fileName [in] protype file name
+    */
+    void CClient::openInfoStream(const StdString& fileName)
+    {
+      std::filebuf* fb = m_infoStream.rdbuf();
+      openStream(fileName, ".out", fb);
+
+      info.write2File(fb);
+      report.write2File(fb);
+    }
+
+    //! Write the info logs to standard output
+    void CClient::openInfoStream()
+    {
+      info.write2StdOut();
+      report.write2StdOut();
+    }
+
+    //! Close the info logs file if it opens
+    void CClient::closeInfoStream()
+    {
+      if (m_infoStream.is_open()) m_infoStream.close();
+    }
+
+    /*!
+    * \brief Open a file stream to write the error log
+    * Open a file stream with a specific file name suffix+rank
+    * to write the error log.
+    * \param fileName [in] protype file name
+    */
+    void CClient::openErrorStream(const StdString& fileName)
+    {
+      std::filebuf* fb = m_errorStream.rdbuf();
+      openStream(fileName, ".err", fb);
+
+      error.write2File(fb);
+    }
+
+    //! Write the error log to standard error output
+    void CClient::openErrorStream()
+    {
+      error.write2StdErr();
+    }
+
+    //! Close the error log file if it opens
+    void CClient::closeErrorStream()
+    {
+      if (m_errorStream.is_open()) m_errorStream.close();
+    }
 }
Index: XIOS/branchs/xios-1.0/src/client.hpp
===================================================================
--- XIOS/branchs/xios-1.0/src/client.hpp	(revision 547)
+++ XIOS/branchs/xios-1.0/src/client.hpp	(revision 548)
@@ -9,30 +9,38 @@
     class CClient
     {
-       public:
+      public:
+        static void initialize(const string& codeId, MPI_Comm& localComm, MPI_Comm& returnComm);
+        static void finalize(void);
+        static void registerContext(const string& id, MPI_Comm contextComm);
 
-       static void initialize(const string& codeId,MPI_Comm& localComm,MPI_Comm& returnComm) ;
-       static void finalize(void) ;
-       static void registerContext(const string& id,MPI_Comm contextComm) ;
+        static MPI_Comm intraComm;
+        static MPI_Comm interComm;
+        static int serverLeader;
+        static bool is_MPI_Initialized ;
 
-       static MPI_Comm intraComm ;
-       static MPI_Comm interComm ;
-       static int serverLeader;
-       static bool is_MPI_Initialized ;
-
-       public:
+        //! Get rank of the current process
         static int getRank();
 
+        //! Open a file stream to write the info logs
         static void openInfoStream(const StdString& fileName);
-
+        //! Write the info logs to standard output
         static void openInfoStream();
-
+        //! Close the info logs file if it opens
         static void closeInfoStream();
 
-       protected:
-       static int rank;
-       static StdOFStream m_infoStream;
+        //! Open a file stream to write the error log
+        static void openErrorStream(const StdString& fileName);
+        //! Write the error log to standard error output
+        static void openErrorStream();
+        //! Close the error log file if it opens
+        static void closeErrorStream();
 
+      protected:
+        static int rank;
+        static StdOFStream m_infoStream;
+        static StdOFStream m_errorStream;
 
-    } ;
+        static void openStream(const StdString& fileName, const StdString& ext, std::filebuf* fb);
+    };
 }
 
Index: XIOS/branchs/xios-1.0/src/cxios.cpp
===================================================================
--- XIOS/branchs/xios-1.0/src/cxios.cpp	(revision 547)
+++ XIOS/branchs/xios-1.0/src/cxios.cpp	(revision 548)
@@ -27,6 +27,5 @@
   size_t CXios::defaultBufferSize=1024*1024*100 ; // 100Mo
   double CXios::defaultBufferServerFactorSize=2 ;
-  bool CXios::printInfo2File;
-  bool CXios::isServerSide;
+  bool CXios::printLogs2Files;
 
 
@@ -38,5 +37,5 @@
     usingServer=getin<bool>("using_server",false) ;
     info.setLevel(getin<int>("info_level",0)) ;
-    printInfo2File=getin<bool>("print_file",false);
+    printLogs2Files=getin<bool>("print_file",false);
     bufferSize=getin<size_t>("buffer_size",defaultBufferSize) ;
     bufferServerFactorSize=getin<double>("buffer_server_factor_size",defaultBufferServerFactorSize) ;
@@ -54,11 +53,17 @@
     CClient::initialize(codeId,localComm,returnComm) ;
 
-    if (usingServer) isServerSide = isServer=false;
-    else isServerSide = isServer=true;
+    if (usingServer) isServer=false;
+    else isServer=true;
 
-    if (printInfo2File)
+    if (printLogs2Files)
+    {
       CClient::openInfoStream(clientFile);
+      CClient::openErrorStream(clientFile);
+    }
     else
+    {
       CClient::openInfoStream();
+      CClient::openErrorStream();
+    }
   }
 
@@ -82,13 +87,17 @@
     isServer=false ;
 
-    isServerSide = true;
-
     // Initialize all aspects MPI
     CServer::initialize();
 
-    if (printInfo2File)
+    if (printLogs2Files)
+    {
       CServer::openInfoStream(serverFile);
+      CServer::openErrorStream(serverFile);
+    }
     else
+    {
       CServer::openInfoStream();
+      CServer::openErrorStream();
+    }
 
     // Enter the loop to listen message from Client
Index: XIOS/branchs/xios-1.0/src/cxios.hpp
===================================================================
--- XIOS/branchs/xios-1.0/src/cxios.hpp	(revision 547)
+++ XIOS/branchs/xios-1.0/src/cxios.hpp	(revision 548)
@@ -35,5 +35,5 @@
      static MPI_Comm globalComm ;
 
-     static bool printInfo2File;
+     static bool printLogs2Files; //!< Printing out logs into files
      static bool usingOasis ;
      static bool usingServer ;
@@ -49,7 +49,4 @@
      //! Setting xios NOT to use server mode
      static void setNotUsingServer();
-
-      //! A silly variable to detect whether one process is in client or server side. Should be removed on refactoring code
-     static bool isServerSide;
 
   } ;
Index: XIOS/branchs/xios-1.0/src/exception.cpp
===================================================================
--- XIOS/branchs/xios-1.0/src/exception.cpp	(revision 547)
+++ XIOS/branchs/xios-1.0/src/exception.cpp	(revision 548)
@@ -6,4 +6,5 @@
 #include "server.hpp"
 #include "cxios.hpp"
+#include "log.hpp"
 
 namespace xios
@@ -34,32 +35,7 @@
 #else
      {
-      int numDigit = 0;
-      int size = 0;
-      MPI_Comm_size(CXios::globalComm, &size);
-      while (size)
-      {
-        size /= 10;
-        ++numDigit;
-      }
-
-      StdOFStream fileStream;
-      StdStringStream fileNameErr;
-      std::streambuf* psbuf;
-      if (CXios::isServerSide)
-        fileNameErr << CXios::serverFile << "_" << std::setfill('0')
-                    << std::setw(numDigit) << CServer::getRank() << ".err";
-      else
-        fileNameErr << CXios::clientFile << "_" << std::setfill('0')
-                    << std::setw(numDigit) << CClient::getRank() << ".err";
-
-
-      fileStream.open(fileNameErr.str().c_str(), std::ofstream::out);
-      psbuf = fileStream.rdbuf();
-      std::cerr.rdbuf(psbuf);
-      std::cerr << this->getMessage() << std::endl;
-      fileStream.close();
+      error << this->getMessage() << std::endl;
       abort();
       }
-
 #endif
    }
Index: XIOS/branchs/xios-1.0/src/log.cpp
===================================================================
--- XIOS/branchs/xios-1.0/src/log.cpp	(revision 547)
+++ XIOS/branchs/xios-1.0/src/log.cpp	(revision 548)
@@ -5,3 +5,4 @@
   CLog info("info") ;
   CLog report("report") ;
+  CLog error("error", cerr.rdbuf()) ;
 }
Index: XIOS/branchs/xios-1.0/src/log.hpp
===================================================================
--- XIOS/branchs/xios-1.0/src/log.hpp	(revision 547)
+++ XIOS/branchs/xios-1.0/src/log.hpp	(revision 548)
@@ -13,5 +13,6 @@
   {
     public :
-    CLog(const string& name_) : ostream(cout.rdbuf()),level(0),name(name_), strBuf_(cout.rdbuf()) {}
+    CLog(const string& name_, std::streambuf* sBuff = cout.rdbuf())
+      : ostream(sBuff), level(0), name(name_), strBuf_(sBuff) {}
     CLog& operator()(int l)
     {
@@ -30,9 +31,13 @@
 
   public:
-    //! Write info into a file with its streambuf
+    //! Write log into a file with its streambuf
     void write2File(std::streambuf* sBuff) { changeStreamBuff(sBuff); }
 
-    //! Write info into standard output
+    //! Write log into standard output
     void write2StdOut() { changeStreamBuff(cout.rdbuf()); }
+
+    //! Write log into standard error output
+    void write2StdErr() { changeStreamBuff(cerr.rdbuf()); }
+
   private:
     /*!
@@ -43,5 +48,4 @@
     void changeStreamBuff(std::streambuf* sBuff) { strBuf_ = sBuff; rdbuf(sBuff); }
 
-    private :
     int level ;
     string name ;
@@ -51,4 +55,5 @@
   extern CLog info;
   extern CLog report;
+  extern CLog error;
 }
 #endif
Index: XIOS/branchs/xios-1.0/src/server.cpp
===================================================================
--- XIOS/branchs/xios-1.0/src/server.cpp	(revision 547)
+++ XIOS/branchs/xios-1.0/src/server.cpp	(revision 548)
@@ -21,4 +21,5 @@
     int CServer::rank = INVALID_RANK;
     StdOFStream CServer::m_infoStream;
+    StdOFStream CServer::m_errorStream;
     map<string,CContext*> CServer::contextList ;
     bool CServer::finished=false ;
@@ -407,44 +408,83 @@
      }
 
-     /*!
-      * \brief Open file stream to write in
-      *   Opening a file stream with a specific file name suffix-server+rank
-      * \param [in] protype file name
-     */
-     void CServer::openInfoStream(const StdString& fileName)
-     {
-       std::filebuf* fb = m_infoStream.rdbuf();
-       StdStringStream fileNameServer;
-       int numDigit = 0;
-       int size = 0;
-       MPI_Comm_size(CXios::globalComm, &size);
-       while (size)
-       {
-         size /= 10;
-         ++numDigit;
-       }
-
-       fileNameServer << fileName <<"_" << std::setfill('0') << std::setw(numDigit) << getRank() << ".out";
-       fb->open(fileNameServer.str().c_str(), std::ios::out);
-       if (!fb->is_open())
-       ERROR("void CServer::openInfoStream(const StdString& fileName)",
-            <<endl<< "Can not open <"<<fileNameServer<<"> file to write" );
-
-       info.write2File(fb);
-       report.write2File(fb);
-     }
-
-     //! Open stream for standard output
-     void CServer::openInfoStream()
-     {
-       info.write2StdOut();
-       report.write2StdOut();
-     }
-
-     //! Close opening stream
-     void CServer::closeInfoStream()
-     {
-       if (m_infoStream.is_open()) m_infoStream.close();
-     }
-
+    /*!
+    * Open a file specified by a suffix and an extension and use it for the given file buffer.
+    * The file name will be suffix+rank+extension.
+    * 
+    * \param fileName[in] protype file name
+    * \param ext [in] extension of the file
+    * \param fb [in/out] the file buffer
+    */
+    void CServer::openStream(const StdString& fileName, const StdString& ext, std::filebuf* fb)
+    {
+      StdStringStream fileNameClient;
+      int numDigit = 0;
+      int size = 0;
+      MPI_Comm_size(CXios::globalComm, &size);
+      while (size)
+      {
+        size /= 10;
+        ++numDigit;
+      }
+
+      fileNameClient << fileName << "_" << std::setfill('0') << std::setw(numDigit) << getRank() << ext;
+      fb->open(fileNameClient.str().c_str(), std::ios::out);
+      if (!fb->is_open())
+        ERROR("void CServer::openStream(const StdString& fileName, const StdString& ext, std::filebuf* fb)",
+              << std::endl << "Can not open <" << fileNameClient << "> file to write the server log(s).");
+    }
+
+    /*!
+    * \brief Open a file stream to write the info logs
+    * Open a file stream with a specific file name suffix+rank
+    * to write the info logs.
+    * \param fileName [in] protype file name
+    */
+    void CServer::openInfoStream(const StdString& fileName)
+    {
+      std::filebuf* fb = m_infoStream.rdbuf();
+      openStream(fileName, ".out", fb);
+
+      info.write2File(fb);
+      report.write2File(fb);
+    }
+
+    //! Write the info logs to standard output
+    void CServer::openInfoStream()
+    {
+      info.write2StdOut();
+      report.write2StdOut();
+    }
+
+    //! Close the info logs file if it opens
+    void CServer::closeInfoStream()
+    {
+      if (m_infoStream.is_open()) m_infoStream.close();
+    }
+
+    /*!
+    * \brief Open a file stream to write the error log
+    * Open a file stream with a specific file name suffix+rank
+    * to write the error log.
+    * \param fileName [in] protype file name
+    */
+    void CServer::openErrorStream(const StdString& fileName)
+    {
+      std::filebuf* fb = m_errorStream.rdbuf();
+      openStream(fileName, ".err", fb);
+
+      error.write2File(fb);
+    }
+
+    //! Write the error log to standard error output
+    void CServer::openErrorStream()
+    {
+      error.write2StdErr();
+    }
+
+    //! Close the error log file if it opens
+    void CServer::closeErrorStream()
+    {
+      if (m_errorStream.is_open()) m_errorStream.close();
+    }
 }
Index: XIOS/branchs/xios-1.0/src/server.hpp
===================================================================
--- XIOS/branchs/xios-1.0/src/server.hpp	(revision 547)
+++ XIOS/branchs/xios-1.0/src/server.hpp	(revision 548)
@@ -11,50 +11,57 @@
     class CServer
     {
-       public:
+      public:
+        static void initialize(void);
+        static void finalize(void);
+        static void eventLoop(void);
+        static void contextEventLoop(void);
+        static void listenContext(void);
+        static void listenFinalize(void);
+        static void recvContextMessage(void* buff,int count);
+        static void listenRootContext(void);
+        static void listenRootFinalize(void);
+        static void registerContext(void* buff,int count, int leaderRank=0);
 
-       static void initialize(void) ;
-       static void finalize(void) ;
-       static void eventLoop(void) ;
-       static void contextEventLoop(void) ;
-       static void listenContext(void) ;
-       static void listenFinalize(void) ;
-       static void recvContextMessage(void* buff,int count) ;
-       static void listenRootContext(void) ;
-       static void listenRootFinalize(void) ;
-       static void registerContext(void* buff,int count, int leaderRank=0) ;
+        static MPI_Comm intraComm;
+        static list<MPI_Comm> interComm;
+        static CEventScheduler* eventScheduler;
 
-       static MPI_Comm intraComm ;
-       static list<MPI_Comm> interComm ;
-       static CEventScheduler* eventScheduler ;
+        struct contextMessage
+        {
+          int nbRecv;
+          int leaderRank;
+        };
 
-       struct contextMessage
-       {
-         int nbRecv ;
-         int leaderRank ;
-       } ;
+        static bool isRoot;
 
-       static bool isRoot ;
+        static map<string,CContext*> contextList;
+        static bool finished;
+        static bool is_MPI_Initialized;
 
-       static map<string,CContext*> contextList ;
-       static bool finished ;
-       static bool is_MPI_Initialized ;
+      public:
+        //! Get rank of the current process
+        static int getRank();
 
-       public:
-         //! Get rank of the current process
-         static int getRank();
-
-        //! Print Information into a file
+        //! Open a file stream to write the info logs
         static void openInfoStream(const StdString& fileName);
-
-        //! Print information to standard output
+        //! Write the info logs to standard output
         static void openInfoStream();
-
-        //! Close Info stream (closing file)
+        //! Close the info logs file if it opens
         static void closeInfoStream();
 
-       private:
+        //! Open a file stream to write the error log
+        static void openErrorStream(const StdString& fileName);
+        //! Write the error log to standard error output
+        static void openErrorStream();
+        //! Close the error log file if it opens
+        static void closeErrorStream();
+
+      private:
+        static int rank;
         static StdOFStream m_infoStream;
-        static int rank ;
-    } ;
+        static StdOFStream m_errorStream;
+
+        static void openStream(const StdString& fileName, const StdString& ext, std::filebuf* fb);
+    };
 }
 
