Index: /trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMLogViewer.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMLogViewer.cpp	(revision 28343)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMLogViewer.cpp	(revision 28344)
@@ -164,5 +164,5 @@
 {
     /* Clearing old data if any */
-    mLogFilesList.clear();
+    mLogFiles.clear();
     mLogList->setEnabled (true);
     while (mLogList->count())
@@ -175,17 +175,35 @@
     bool isAnyLogPresent = false;
 
-    /* Entering log files folder */
-    QString logFilesPath = mMachine.GetLogFolder();
-    QDir logFilesDir (logFilesPath);
-    if (logFilesDir.exists())
-    {
-        /* Reading log files folder */
-        QStringList filters;
-        filters << "*.log" << "*.log.*";
-        logFilesDir.setNameFilters (filters);
-        QStringList logList = logFilesDir.entryList (QDir::Files);
-        if (!logList.empty()) isAnyLogPresent = true;
-        foreach (QString logFile, logList)
-            loadLogFile (logFilesDir.filePath (logFile));
+    const CSystemProperties &sys = vboxGlobal().virtualBox().GetSystemProperties();
+    int cMaxLogs = sys.GetLogHistoryCount();
+    for (int i=0; i <= cMaxLogs; ++i)
+    {
+        /* Query the log file name for index i */
+        QString file = mMachine.QueryLogFilename(i);
+        if (!file.isEmpty())
+        {
+            /* Try to read the log file with the index i */
+            ULONG uOffset = 0;
+            QString text;
+            while (true)
+            {
+                QVector<BYTE> data = mMachine.ReadLog(i, uOffset, _1M);
+                if (data.size() == 0)
+                    break;
+                text.append(QString::fromUtf8((char*)data.data(), data.size()));
+                uOffset += data.size();
+            }
+            /* Anything read at all? */
+            if (uOffset > 0)
+            {
+                /* Create a log viewer page and append the read text to it */
+                QTextEdit *logViewer = createLogPage(QFileInfo(file).fileName());
+                logViewer->setPlainText(text);
+                /* Add the actual file name and the QTextEdit containing the
+                   content to a list. */
+                mLogFiles << qMakePair(file, logViewer);
+                isAnyLogPresent = true;
+            }
+        }
     }
 
@@ -198,5 +216,5 @@
             "<b>Refresh</b> button to rescan the log folder "
             "<nobr><b>%1</b></nobr>.</p>")
-            .arg (logFilesPath));
+            .arg (mMachine.GetLogFolder()));
         /* We don't want it to remain white */
         QPalette pal = dummyLog->palette();
@@ -222,5 +240,5 @@
 {
     /* Prepare "save as" dialog */
-    QFileInfo fileInfo (mLogFilesList [mLogList->currentIndex()]);
+    QFileInfo fileInfo (mLogFiles.at(mLogList->currentIndex()).first);
     QDateTime dtInfo = fileInfo.lastModified();
     QString dtString = dtInfo.toString ("yyyy-MM-dd-hh-mm-ss");
@@ -236,12 +254,10 @@
     {
         /* Reread log data */
-        QFile oldFile (mLogFilesList [mLogList->currentIndex()]);
         QFile newFile (newFileName);
-        if (!oldFile.open (QIODevice::ReadOnly) ||
-            !newFile.open (QIODevice::WriteOnly))
+        if (!newFile.open (QIODevice::WriteOnly))
             return;
 
         /* Save log data into the new file */
-        newFile.write (oldFile.readAll());
+        newFile.write (mLogFiles.at(mLogList->currentIndex()).second->toPlainText().toUtf8());
     }
 }
@@ -255,6 +271,6 @@
 {
     if (aIndex >= 0 &&
-        aIndex < mLogFilesList.count())
-        setFileForProxyIcon (mLogFilesList.at (aIndex));
+        aIndex < mLogFiles.count())
+        setFileForProxyIcon(mLogFiles.at(aIndex).first);
 }
 
@@ -311,18 +327,4 @@
     if (w)
         w->setFocus();
-}
-
-void VBoxVMLogViewer::loadLogFile (const QString &aFileName)
-{
-    /* Prepare log file */
-    QFile logFile (aFileName);
-    if (!logFile.exists() || !logFile.open (QIODevice::ReadOnly))
-        return;
-
-    /* Read log file and write it into the log page */
-    QTextEdit *logViewer = createLogPage (QFileInfo (aFileName).fileName());
-    logViewer->setPlainText (logFile.readAll());
-
-    mLogFilesList << aFileName;
 }
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMLogViewer.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMLogViewer.h	(revision 28343)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMLogViewer.h	(revision 28344)
@@ -73,5 +73,4 @@
 
     void showEvent (QShowEvent *aEvent);
-    void loadLogFile (const QString &aName);
     QTextEdit* createLogPage (const QString &aPage);
 
@@ -82,6 +81,6 @@
     CMachine              mMachine;
     QTabWidget           *mLogList;
-    QStringList           mLogFilesList;
     VBoxLogSearchPanel   *mSearchPanel;
+    QList< QPair<QString, QTextEdit*> > mLogFiles;
 
     QPushButton *mBtnHelp;
