diff --git a/DynareMain.cc b/DynareMain.cc
index e40afaadc40677a8e2b022484cfb8bb44fc1e161..a43f078de1f9f7111e88be02808aeb40363672ca 100644
--- a/DynareMain.cc
+++ b/DynareMain.cc
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003-2010 Dynare Team
+ * Copyright (C) 2003-2012 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -34,7 +34,7 @@ using namespace std;
    Splitting main() in two parts was necessary because ParsingDriver.h and MacroDriver.h can't be
    included simultaneously (because of Bison limitations).
 */
-void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tmp_terms, bool warn_uninit, bool console,
+void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tmp_terms, bool no_log, bool warn_uninit, bool console,
            bool parallel, const string &parallel_config_file, const string &cluster_name, bool parallel_slave_open_mode,
            bool parallel_test
 #if defined(_WIN32) || defined(__CYGWIN32__)
@@ -45,7 +45,7 @@ void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool
 void
 usage()
 {
-  cerr << "Dynare usage: dynare mod_file [debug] [noclearall] [savemacro[=macro_file]] [onlymacro] [nolinemacro] [notmpterms] [warn_uninit]"
+  cerr << "Dynare usage: dynare mod_file [debug] [noclearall] [savemacro[=macro_file]] [onlymacro] [nolinemacro] [notmpterms] [nolog] [warn_uninit]"
        << " [console] [parallel[=cluster_name]] [conffile=parallel_config_path_and_filename] [parallel_slave_open_mode] [parallel_test] "
        << " [-D<variable>[=<value>]]"
 #if defined(_WIN32) || defined(__CYGWIN32__)
@@ -71,6 +71,7 @@ main(int argc, char **argv)
   bool no_tmp_terms = false;
   bool only_macro = false;
   bool no_line_macro = false;
+  bool no_log = false;
   bool warn_uninit = false;
   bool console = false;
 #if defined(_WIN32) || defined(__CYGWIN32__)
@@ -110,6 +111,8 @@ main(int argc, char **argv)
         no_line_macro = true;
       else if (!strcmp(argv[arg], "notmpterms"))
         no_tmp_terms = true;
+      else if (!strcmp(argv[arg], "nolog"))
+        no_log = true;
       else if (!strcmp(argv[arg], "warn_uninit"))
         warn_uninit = true;
       else if (!strcmp(argv[arg], "console"))
@@ -206,7 +209,7 @@ main(int argc, char **argv)
     return EXIT_SUCCESS;
 
   // Do the rest
-  main2(macro_output, basename, debug, clear_all, no_tmp_terms, warn_uninit, console,
+  main2(macro_output, basename, debug, clear_all, no_tmp_terms, no_log, warn_uninit, console,
         parallel, parallel_config_file, cluster_name, parallel_slave_open_mode, parallel_test
 #if defined(_WIN32) || defined(__CYGWIN32__)
         , cygwin, msvc
diff --git a/DynareMain2.cc b/DynareMain2.cc
index 0892ec27b7946ee98fe44dbb4ea618bb1a7aaae1..8eba44e3a1dcdea9f38fc25096c440ac81f5bfa1 100644
--- a/DynareMain2.cc
+++ b/DynareMain2.cc
@@ -26,7 +26,7 @@ using namespace std;
 #include "ConfigFile.hh"
 
 void
-main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tmp_terms, bool warn_uninit, bool console,
+main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tmp_terms, bool no_log, bool warn_uninit, bool console,
       bool parallel, const string &parallel_config_file, const string &cluster_name, bool parallel_slave_open_mode,
       bool parallel_test
 #if defined(_WIN32) || defined(__CYGWIN32__)
@@ -56,7 +56,7 @@ main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tm
   mod_file->computingPass(no_tmp_terms);
 
   // Write outputs
-  mod_file->writeOutputFiles(basename, clear_all, console, config_file
+  mod_file->writeOutputFiles(basename, clear_all, no_log, console, config_file
 #if defined(_WIN32) || defined(__CYGWIN32__)
                              , cygwin, msvc
 #endif
diff --git a/ModFile.cc b/ModFile.cc
index b6d33b6d5003cf8f00025b263be55af6bc13ec20..e19ff0af05a93468edaa5ac15b57e581c5c46736 100644
--- a/ModFile.cc
+++ b/ModFile.cc
@@ -411,7 +411,7 @@ ModFile::computingPass(bool no_tmp_terms)
 }
 
 void
-ModFile::writeOutputFiles(const string &basename, bool clear_all, bool console, const ConfigFile &config_file
+ModFile::writeOutputFiles(const string &basename, bool clear_all, bool no_log, bool console, const ConfigFile &config_file
 #if defined(_WIN32) || defined(__CYGWIN32__)
                           , bool cygwin, bool msvc
 #endif
@@ -458,12 +458,13 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool console,
               << "% Some global variables initialization" << endl
               << "%" << endl
               << "global_initialization;" << endl
-              << "diary off;" << endl
-              << "logname_ = '" << basename << ".log';" << endl
-              << "if exist(logname_, 'file')" << endl
-              << "    delete(logname_)" << endl
-              << "end" << endl
-              << "diary(logname_)" << endl;
+              << "diary off;" << endl;
+  if (!no_log)
+    mOutputFile << "logname_ = '" << basename << ".log';" << endl
+                << "if exist(logname_, 'file')" << endl
+                << "    delete(logname_)" << endl
+                << "end" << endl
+                << "diary(logname_)" << endl;
 
   if (console)
     mOutputFile << "options_.console_mode = 1;" << endl;
@@ -624,7 +625,8 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool console,
 
   warnings.writeOutput(mOutputFile);
 
-  mOutputFile << "diary off" << endl;
+  if (!no_log)
+    mOutputFile << "diary off" << endl;
 
   mOutputFile.close();
 
diff --git a/ModFile.hh b/ModFile.hh
index cc2c8d4d3d42886d8d9287c4037e653ea4f198fc..d6e336b9aec1cfad5fb4eb1dcf8d4a75a798426c 100644
--- a/ModFile.hh
+++ b/ModFile.hh
@@ -117,7 +117,7 @@ public:
     \param cygwin Should the MEX command of use_dll be adapted for Cygwin?
     \param msvc Should the MEX command of use_dll be adapted for MSVC?
   */
-  void writeOutputFiles(const string &basename, bool clear_all, bool console, const ConfigFile &config_file
+  void writeOutputFiles(const string &basename, bool clear_all, bool no_log, bool console, const ConfigFile &config_file
 #if defined(_WIN32) || defined(__CYGWIN32__)
                         , bool cygwin, bool msvc
 #endif