Package org.wso2.carbon.logging.service

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


      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

        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

    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

  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

    } else {

      try {
        tenantId = tenantManager.getTenantId(tenantDomain);
      } catch (UserStoreException e) {
        throw new LogViewerException("Cannot find tenant id for the given tenant domain.");
      }
    }
    return tenantId;
  }
View Full Code Here

          serviceNames.add(element.getAttributeValue(new QName("name")));
        }
      } catch (Exception e) {
        String msg = "Error in loading Stratos Configurations File: " + configFileName
            + ".";
        throw new LogViewerException(msg, e);
      } finally {
        if (inputStream != null) {
          try {
            inputStream.close();
          } catch (IOException e) {
View Full Code Here

        }

        public void run() {
            try {
                MessageContext msgCtx = ((Axis2MessageContext) synCtx).getAxis2MessageContext();
                Event<MessageContext> event = new Event(msgCtx);
                subscriptions = subscriptionManager.getMatchingSubscriptions(event);
            } catch (EventException e) {
                handleException("Matching subscriptions fetching error", e);
            }
View Full Code Here

     * @throws EventException event
     */
    private void processGetStatusRequest(MessageContext mc,
                                         ResponseMessageBuilder messageBuilder)
            throws AxisFault, EventException {
        Subscription subscription =
                SubscriptionMessageBuilder.createGetStatusMessage(mc);
        if (log.isDebugEnabled()) {
            log.debug("GetStatus request recived for SynapseSubscription ID : " +
                    subscription.getId());
        }
        subscription = subscriptionManager.getSubscription(subscription.getId());
        if (subscription != null) {
            if (log.isDebugEnabled()) {
                log.debug("Sending GetStatus responce for SynapseSubscription ID : " +
                        subscription.getId());
            }
            //send the responce
            SOAPEnvelope soapEnvelope = messageBuilder.genGetStatusResponse(subscription);
            dispatchResponse(soapEnvelope, EventingConstants.WSE_GET_STATUS_RESPONSE,
                    mc, false);
View Full Code Here


    public SynapseSubscription() {
        this.setId(UIDGenerator.generateURNString());
        this.setDeliveryMode(EventingConstants.WSE_DEFAULT_DELIVERY_MODE);
        SubscriptionData subscriptionData = new SubscriptionData();
        subscriptionData.setProperty(SynapseEventingConstants.STATIC_ENTRY, "false");
        this.setSubscriptionData(subscriptionData);
    }
View Full Code Here

TOP

Related Classes of org.wso2.carbon.logging.service.LogViewerException

Copyright © 2018 www.massapicom. 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.