Examples of LogViewerException


Examples of org.wso2.carbon.logging.service.LogViewerException

      logIndex = getLogInfo(tenantId, serviceName);
    } else {
      if (isSuperTenantUser()) {
        logIndex = getLocalLogInfo();
      } else {
        throw new LogViewerException(
            "Syslog Appender needs to be configured to view the log files");
      }
    }
    return logIndex;
  }
View Full Code Here

Examples of org.wso2.carbon.logging.service.LogViewerException

      end = maxLogs;
    }
    try {
      logStream = getInputStream(logFile, tenantId, serviceName);
    } catch (Exception e) {
      throw new LogViewerException("Cannot find the specified file location to the log file",
          e);
    }
    DataInputStream dataInput = new DataInputStream(logStream);
    int index = 1;
    String line;
    try {
      while ((line = dataInput.readLine()) != null) {
        if (index <= end && index > start) {
          logsList.add(line);
        }
        index++;
      }
      dataInput.close();
    } catch (IOException e) {
      throw new LogViewerException("Cannot read the log file", e);
    }
    return logsList.toArray(new String[logsList.size()]);
  }
View Full Code Here

Examples of org.wso2.carbon.logging.service.LogViewerException

    InputStream is;
    int tenantId = getTenantIdForDomain(tenantDomain);
    try {
      is = getInputStream(logFile, tenantId, serviceName);
    } catch (LogViewerException e) {
      throw new LogViewerException("Cannot read InputStream from the file " + logFile, e);
    }
    try {
      byte[] c = new byte[1024];
      int count = 0;
      int readChars = 0;
      while ((readChars = is.read(c)) != -1) {
        for (int i = 0; i < readChars; ++i) {
          if (c[i] == '\n') {
            ++count;
          }
        }
      }
      return count;
    } catch (IOException e) {
      throw new LogViewerException("Cannot read file size from the " + logFile, e);
    } finally {
      try {
        is.close();
      } catch (IOException e) {
        throw new LogViewerException("Cannot close the input stream " + logFile, e);
      }
    }
  }
View Full Code Here

Examples of org.wso2.carbon.logging.service.LogViewerException

    InputStream is;
    try {
      int tenantId = getTenantIdForDomain(tenantDomain);
      is = getInputStream(logFile, tenantId, serviceName);
    } catch (Exception e) {
      throw new LogViewerException("Cannot read InputStream from the file " + logFile, e);
    }
    DataInputStream dataInput = new DataInputStream(is);
    try {
      int count = 1;
      try {
        while ((line = dataInput.readLine()) != null) {
          if (count == lineNo) {
            return line;
          }
          count++;
        }
      } catch (IOException e) {
        throw new LogViewerException("Cannot read line number from the " + logFile, e);
      }
    } finally {
      try {
        dataInput.close();
        is.close();
      } catch (IOException e) {
        throw new LogViewerException("Cannot close the input stream " + logFile, e);
      }
    }
    return null;
  }
View Full Code Here

Examples of org.wso2.carbon.logging.service.LogViewerException

                + LoggingConstants.FILE_SEPARATOR
                + ServerConfiguration.getInstance().getFirstProperty("Name")
                + LoggingConstants.FILE_SEPARATOR;
          }
        } catch (Exception e) {
          throw new LogViewerException("Cannot get log ServerURL for Tenant Service", e);
        }
      } else {
        serverurl = syslogServerURL + LoggingConstants.FILE_SEPARATOR + tenantId
            + LoggingConstants.FILE_SEPARATOR
            + ServerConfiguration.getInstance().getFirstProperty("Name")
View Full Code Here

Examples of org.wso2.carbon.logging.service.LogViewerException

      for (int i = 0; i < maxLen; i++) {
        headLogs[i] = allLogs[i];
      }
      return headLogs;
    } catch (Exception e) {
      throw new LogViewerException("Cannot retrieve logs for bottom up", e);
    }
  }
View Full Code Here

Examples of org.wso2.carbon.logging.service.LogViewerException

      end = maxLogs;
    }
    try {
      logStream = getInputStream(logFile, tenantId, serviceName);
    } catch (Exception e) {
      throw new LogViewerException("Cannot find the specified file location to the log file",
          e);
    }
    DataInputStream dataInput = new DataInputStream(logStream);
    int index = 1;
    String line;
    boolean isSyslogFile;
    try {
      isSyslogFile = isSysLogAppender(tenantId);
    } catch (Exception e1) {
      throw new LogViewerException("Cannot validate syslog appender", e1);
    }
    try {
      while ((line = dataInput.readLine()) != null) {
        if (isSyslogFile) {
          line = removeSyslogHeader(line);
        }
        line = cleanLogHeader(line, tenantId);
        if ((index <= end && index > start)) {
          // When if a log entry has multiple lines (ie exception ect)
          // it waits for valid log header,
          // and add the multiple log lines to the specific log header
          // (since we are reading from bottom up
          // those multiple lines belongs to the next valid log
          // header.
          LogMessage logMessage = null;
          if (isErrorHeader(line)) {
            if (!errorLine.equals("")) {
              errorLine = (String) errorLine.subSequence(0, (errorLine.length() - 1));
              logMessage = getLogMessageForType(errorLine);
              if (logMessage != null) {
                logsList.add(logMessage);
              }
              errorLine = "";
            }
            // when there are log messages with multiple lines one
            // after the other
            // next line is also considered as a error line
            errorLine = line;
          } else if (isFatalHeader(line)) {
            if (!errorLine.equals("")) {
              errorLine = (String) errorLine.subSequence(0, (errorLine.length() - 1));
              logMessage = getLogMessageForType(errorLine);
              if (logMessage != null) {
                logsList.add(logMessage);
              }
              errorLine = "";
            }
            errorLine = line;
          } else if (isTraceHeader(line)) {
            if (!errorLine.equals("")) {
              errorLine = (String) errorLine.subSequence(0, (errorLine.length() - 1));
              logMessage = getLogMessageForType(errorLine);
              if (logMessage != null) {
                logsList.add(logMessage);
              }
              errorLine = "";
            }
            errorLine = line;
          } else if (isInfoHeader(line)) {
            if (!errorLine.equals("")) {
              errorLine = (String) errorLine.subSequence(0, (errorLine.length() - 1));
              logMessage = getLogMessageForType(errorLine);
              if (logMessage != null) {
                logsList.add(logMessage);
              }
              errorLine = "";
            }
            errorLine = line;
          } else if (isWarnHeader(line)) {
            if (!errorLine.equals("")) {
              errorLine = (String) errorLine.subSequence(0, (errorLine.length() - 1));
              logMessage = getLogMessageForType(errorLine);
              if (logMessage != null) {
                logsList.add(logMessage);
              }
              errorLine = "";
            }
            errorLine = line;
          } else if (isDebugHeader(line)) {
            if (!errorLine.equals("")) {
              errorLine = (String) errorLine.subSequence(0, (errorLine.length() - 1));
              logMessage = getLogMessageForType(errorLine);
              if (logMessage != null) {
                logsList.add(logMessage);
              }
              errorLine = "";
            }
            errorLine = line;
          } else if (!isLogHeader(line)) {
            // if a log line has no valid log header that log line
            // is considered as a error line.
            errorLine = errorLine + line + LoggingConstants.RegexPatterns.NEW_LINE;
          } else if (isLogHeader(line)) {
            if (!errorLine.equals("")) {
              errorLine = (String) errorLine.subSequence(0, (errorLine.length() - 1));
              logMessage = getLogMessageForType(errorLine);
              if (logMessage != null) {
                logsList.add(logMessage);
              }
              errorLine = "";
            }
            logMessage = getLogMessageForType(line);
            if (logMessage != null) {
              logsList.add(logMessage);
            }
          } else {
            log.warn("The log message  " + line + " is ignored.");
          }
        }
        index++;
      }
      if (!errorLine.equals("")) {
        LogMessage logMessage = getLogMessageForType(errorLine);
        if (logMessage != null) {
          logsList.add(logMessage);
        } else {
          log.warn("The log message " + errorLine + " is ignored.");
        }
      }
      dataInput.close();
    } catch (IOException e) {
      throw new LogViewerException("Cannot read the log file", e);
    }
    return logsList.toArray(new LogMessage[logsList.size()]);
  }
View Full Code Here

Examples of org.wso2.carbon.logging.service.LogViewerException

        inputStream = getLogDataStream(logFile, tenantId, serviceName);
      } else {
        if (isSuperTenantUser()) {
          inputStream = getLocalInputStream(logFile);
        } else {
          throw new LogViewerException("Syslog Properties are not properly configured");
        }
      }
      return inputStream;
    } catch (Exception e) {
      throw new LogViewerException("Error getting the file inputstream", e);
    }

  }
View Full Code Here

Examples of org.wso2.carbon.logging.service.LogViewerException

    InputStream logStream;
    try {
      if (isSysLogAppender(tenantId)) {
        logStream = getLogDataStream("", tenantId, serviceName);
      } else {
        throw new LogViewerException("Syslog Properties are not properly configured");
      }

    } catch (HttpException e) {
      throw new LogViewerException("Cannot establish the connection to the syslog server", e);
    } catch (IOException e) {
      throw new LogViewerException("Cannot find the specified file location to the log file",
          e);
    } catch (Exception e) {
      throw new LogViewerException("Cannot find the specified file location to the log file",
          e);
    }
    DataInputStream dataInput = new DataInputStream(logStream);
    String line;
    ArrayList<LogInfo> logs = new ArrayList<LogInfo>();
    Pattern pattern = Pattern.compile(LoggingConstants.RegexPatterns.SYS_LOG_FILE_NAME_PATTERN);
    try {
      while ((line = dataInput.readLine()) != null) {
        String fileNameLinks[] = line
            .split(LoggingConstants.RegexPatterns.LINK_SEPARATOR_PATTERN);
        String fileDates[] = line
            .split((LoggingConstants.RegexPatterns.SYSLOG_DATE_SEPARATOR_PATTERN));
        String dates[] = null;
        String sizes[] = null;
        if (fileDates.length == 3) {
          dates = fileDates[1]
              .split(LoggingConstants.RegexPatterns.COLUMN_SEPARATOR_PATTERN);
          sizes = fileDates[2]
              .split(LoggingConstants.RegexPatterns.COLUMN_SEPARATOR_PATTERN);
        }
        if (fileNameLinks.length == 2) {
          String logFileName[] = fileNameLinks[1]
              .split(LoggingConstants.RegexPatterns.GT_PATTARN);
          Matcher matcher = pattern.matcher(logFileName[0]);
          if (matcher.find()) {
            if (logFileName != null && dates != null && sizes != null) {
              String logName = logFileName[0].replace(
                  LoggingConstants.RegexPatterns.BACK_SLASH_PATTERN, "");
              logName = logName.replaceAll("%20", " ");
              LogInfo log = new LogInfo(logName, dates[0], sizes[0]);
              logs.add(log);
            }
          }
        }
      }
      dataInput.close();
    } catch (IOException e) {
      throw new LogViewerException("Cannot find the specified file location to the log file",
          e);
    }
    return getSortedLogInfo(logs.toArray(new LogInfo[logs.size()]));
  }
View Full Code Here

Examples of org.wso2.carbon.logging.service.LogViewerException

  private boolean isSyslogConfiguredInRegistry() throws LogViewerException {
    try {
      return LoggingUtil.isSyslogConfigured();
    } catch (Exception e) {
      throw new LogViewerException(
          "Cannot access the registry configuration to get syslogappender", e);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.