Index: /trunk/FACT++/src/Main.h
===================================================================
--- /trunk/FACT++/src/Main.h	(revision 17347)
+++ /trunk/FACT++/src/Main.h	(revision 17348)
@@ -21,4 +21,5 @@
 {
     using namespace std;
+    namespace fs = boost::filesystem;
 
     void SetupConfiguration(Configuration &conf)
@@ -31,4 +32,5 @@
             ("host",       var<string>(),                  "Address with which the Dim nameserver can connect to this host (overwites DIM_HOST_NODE environment variable)")
             ("log,l",      var<string>(n), "Name of local log-file")
+            ("logpath",    var<string>(),  "Absolute path to log-files (default: excutable's directory)")
             ("no-log",     po_switch(),    "Supress log-file")
             ("append-log", po_bool(),      "Append log information to local log-file")
@@ -38,4 +40,5 @@
             ("exec,e",     vars<string>(), "Execute one or more scrips at startup ('file:N' - start at label N)")
             ("arg:*",      var<string>(),  "Arguments for script execution with --exc, e.g. --arg:ra='12.5436'")
+            ("home",       var<string>(),  "Path to home directory (used as default for logpath if standard log files not writable)")
             ("quit",       po_switch(),    "Quit after startup");
         ;
@@ -43,4 +46,5 @@
         conf.AddEnv("dns",  "DIM_DNS_NODE");
         conf.AddEnv("host", "DIM_HOST_NODE");
+        conf.AddEnv("home", "HOME");
 
         conf.AddOptions(config);
@@ -87,6 +91,36 @@
 
         // -----------------------------------------------------------------
-
-        static T shell(conf.GetName().c_str(),
+        const fs::path program(conf.GetName());
+
+        // Split path to program into path and filename
+        const string prgpath = program.parent_path().string();
+
+#if BOOST_VERSION < 104600
+        const string prgname = program.filename();
+#else
+        const string prgname = program.filename().string();
+#endif
+
+        fs::path path = conf.Has("logpath") ? conf.Get<string>("logpath") : "";
+
+        // No explicit path given
+        if (path.empty())
+        {
+            path = prgpath;
+
+            // default path not accessible
+            if (access(prgpath.empty() ? "." : prgpath.c_str(), W_OK))
+            {
+                path  = conf.Get<string>("home");
+                path /= ".fact++";
+            }
+        }
+
+        // Create directories if necessary
+        fs::create_directories(path);
+
+        // -----------------------------------------------------------------
+
+        static T shell((path/prgname).string().c_str(),
                        conf.Has("console") ? conf.Get<int>("console")!=1 : conf.Get<bool>("null"));
 
@@ -108,21 +142,20 @@
 
         if (conf.Has("log") && !conf.Get<bool>("no-log"))
-            if (!wout.OpenLogFile(conf.Get<string>("log"), conf.Get<bool>("append-log")))
-                win << kRed << "ERROR - Couldn't open log-file " << conf.Get<string>("log") << ": " << strerror(errno) << endl;
+        {
+#if BOOST_VERSION < 104600
+            const fs::path file = fs::path(conf.Get<string>("log")).filename();
+#else
+            const fs::path file = fs::path(conf.Get<string>("log")).filename();
+#endif
+            if (!wout.OpenLogFile((path/file).string(), conf.Get<bool>("append-log")))
+                win << kYellow << "WARNING - Couldn't open log-file " << path.string() << ": " << strerror(errno) << endl;
+        }
 
         S io_service(wout);
 
-        const boost::filesystem::path path(conf.GetName());
-
-        const string pname = path.parent_path().string();
-#if BOOST_VERSION < 104600
-        const string fname = path.filename();
-#else
-        const string fname = path.filename().string();
-#endif
         const Time now;
         io_service.Write(now, "/----------------------- Program ------------------------");
-        io_service.Write(now, "| Program:  "PACKAGE_STRING" ("+fname+":"+to_string(getpid())+")");
-        io_service.Write(now, "| CallPath: "+pname);
+        io_service.Write(now, "| Program:  "PACKAGE_STRING" ("+prgname+":"+to_string(getpid())+")");
+        io_service.Write(now, "| CallPath: "+prgpath);
         io_service.Write(now, "| Compiled: "__DATE__" "__TIME__);
         io_service.Write(now, "| Revision: "REVISION);
