diff --git a/indra/llvfs/lldir.cpp b/indra/llvfs/lldir.cpp
index c344a88b60a34d15b6a24500bbe0baa811099cf7..175e68c13d5098fd36017f12ece750dee2eb30a6 100755
--- a/indra/llvfs/lldir.cpp
+++ b/indra/llvfs/lldir.cpp
@@ -89,7 +89,8 @@ LLDir::LLDir()
 	mTempDir(""),
 	mDirDelimiter("/"), // fallback to forward slash if not overridden
 	mLanguage("en"),
-	mUserName("undefined")
+	mUserName("undefined"),
+	mGrid("")
 {
 }
 
@@ -880,7 +881,7 @@ std::string LLDir::getForbiddenFileChars()
 	return "\\/:*?\"<>|";
 }
 
-void LLDir::setLindenUserDir(const std::string &username)
+void LLDir::setLindenUserDir(const std::string &username, const std::string &gridname)
 {
 	// if the username isn't set, that's bad
 	if (!username.empty())
@@ -890,7 +891,13 @@ void LLDir::setLindenUserDir(const std::string &username)
 		std::string userlower(username);
 		LLStringUtil::toLower(userlower);
 		LLStringUtil::replaceChar(userlower, ' ', '_');
-		mLindenUserDir = add(getOSUserAppDir(), userlower);
+		std::string gridlower(gridname);
+		LLStringUtil::toLower(gridlower);
+		LLStringUtil::replaceChar(gridlower, ' ', '_');
+		const std::string& logname = (gridlower.empty())
+			? userlower : userlower.append(".").append(gridlower);
+		
+		mLindenUserDir = add(getOSUserAppDir(), logname);
 	}
 	else
 	{
@@ -914,10 +921,12 @@ void LLDir::setChatLogsDir(const std::string &path)
 
 void LLDir::updatePerAccountChatLogsDir()
 {
-	mPerAccountChatLogsDir = add(getChatLogsDir(), mUserName);
+	const std::string& logname = (mGrid.empty())
+		? mUserName : mUserName.append(".").append(mGrid);
+	mPerAccountChatLogsDir = add(getChatLogsDir(), logname);
 }
 
-void LLDir::setPerAccountChatLogsDir(const std::string &username)
+void LLDir::setPerAccountChatLogsDir(const std::string &username, const std::string &gridname)
 {
 	// if both first and last aren't set, assume we're grabbing the cached dir
 	if (!username.empty())
@@ -927,8 +936,12 @@ void LLDir::setPerAccountChatLogsDir(const std::string &username)
 		std::string userlower(username);
 		LLStringUtil::toLower(userlower);
 		LLStringUtil::replaceChar(userlower, ' ', '_');
-
+		std::string gridlower(gridname);
+		LLStringUtil::toLower(gridlower);
+		LLStringUtil::replaceChar(gridlower, ' ', '_');
+		
 		mUserName = userlower;
+		mGrid = gridlower;
 		updatePerAccountChatLogsDir();
 	}
 	else
diff --git a/indra/llvfs/lldir.h b/indra/llvfs/lldir.h
index cccefd2e9b10f19fcdd773935d6bb78262373312..4e73d778b2f92469c3a0adfe613f05f9bb41baf0 100755
--- a/indra/llvfs/lldir.h
+++ b/indra/llvfs/lldir.h
@@ -181,8 +181,8 @@ class LLDir
 
 
 	virtual void setChatLogsDir(const std::string &path);		// Set the chat logs dir to this user's dir
-	virtual void setPerAccountChatLogsDir(const std::string &username);		// Set the per user chat log directory.
-	virtual void setLindenUserDir(const std::string &username);		// Set the linden user dir to this user's dir
+	virtual void setPerAccountChatLogsDir(const std::string &username, const std::string &gridname);		// Set the per user chat log directory.
+	virtual void setLindenUserDir(const std::string &username, const std::string &gridname);		// Set the linden user dir to this user's dir
 	virtual void setSkinFolder(const std::string &skin_folder, const std::string& language);
 	virtual std::string getSkinFolder() const;
 	virtual std::string getLanguage() const;
@@ -247,6 +247,7 @@ protected:
 	std::string mLLPluginDir;			// Location for plugins and plugin shell
     static std::string sDumpDir;            // Per-run crash report subdir of log directory.
 	std::string mUserName;				// Current user name
+	std::string mGrid;					// Current grid
 };
 
 void dir_exists_or_crash(const std::string &dir_name);
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index d1bf98c635a0f4e03566bc35f9a2a5822c771176..95500d72fff263c4cb694c7a015b5f8031cb2c2b 100755
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -930,8 +930,9 @@ bool idle_startup()
 		gDebugInfo["LoginName"] = userid;                                                                              
          
 		// create necessary directories
+		const std::string& gridlabel = !LLGridManager::getInstance()->isInSecondlife() ? LLGridManager::getInstance()->getGridLabel() : LLStringUtil::null;
 		// *FIX: these mkdir's should error check
-		gDirUtilp->setLindenUserDir(userid);
+		gDirUtilp->setLindenUserDir(userid, gridlabel);
 		LLFile::mkdir(gDirUtilp->getLindenUserDir());
 
 		// As soon as directories are ready initialize notification storages
@@ -974,7 +975,7 @@ bool idle_startup()
 		{
 			gDirUtilp->setChatLogsDir(gSavedPerAccountSettings.getString("InstantMessageLogPath"));		
 		}
-		gDirUtilp->setPerAccountChatLogsDir(userid);  
+		gDirUtilp->setPerAccountChatLogsDir(userid, gridlabel);
 		
 		LLFile::mkdir(gDirUtilp->getChatLogsDir());
 		LLFile::mkdir(gDirUtilp->getPerAccountChatLogsDir());
diff --git a/indra/newview/llviewernetwork.cpp b/indra/newview/llviewernetwork.cpp
index db327fd64f5237f52d22c0db74baa77f6f0de517..880a95d19b5da826dd74cf3b213e8b93dbc94501 100755
--- a/indra/newview/llviewernetwork.cpp
+++ b/indra/newview/llviewernetwork.cpp
@@ -119,14 +119,14 @@ void LLGridManager::initialize(const std::string& grid_file)
 	mGridFile = grid_file;
 	// as we don't want an attacker to override our grid list
 	// to point the default grid to an invalid grid
-  	addSystemGrid("Second Life Main Grid (Agni)",
+  	addSystemGrid("Second Life",
 				  MAINGRID,
 				  MAIN_GRID_LOGIN_URI,
 				  "https://secondlife.com/helpers/",
 				  DEFAULT_LOGIN_PAGE,
 				  SL_UPDATE_QUERY_URL,
 				  "Agni");
-	addSystemGrid("Second Life Beta Test Grid (Aditi)",
+	addSystemGrid("Second Life Beta",
 				  "util.aditi.lindenlab.com",
 				  "https://login.aditi.lindenlab.com/cgi-bin/login.cgi",
 				  "http://aditi-secondlife.webdev.lindenlab.com/helpers/",