本文整理汇总了Java中com.google.appengine.api.log.RequestLogs.getAppLogLines方法的典型用法代码示例。如果您正苦于以下问题:Java RequestLogs.getAppLogLines方法的具体用法?Java RequestLogs.getAppLogLines怎么用?Java RequestLogs.getAppLogLines使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.appengine.api.log.RequestLogs
的用法示例。
在下文中一共展示了RequestLogs.getAppLogLines方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doGet
import com.google.appengine.api.log.RequestLogs; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
resp.setContentType("text/plain");
if (req.getParameter("printLogs") != null) {
LogService ls = LogServiceFactory.getLogService();
LogQuery query = withIncludeAppLogs(true).minLogLevel(LogService.LogLevel.FATAL);
for (RequestLogs logs : ls.fetch(query)) {
for (AppLogLine logLine : logs.getAppLogLines()) {
if (logLine.getLogLevel().equals(LogService.LogLevel.FATAL)) {
resp.getWriter().println(logLine);
}
}
}
} else {
Logger logger = Logger.getLogger("com.foo");
resp.getWriter().println(logger.getLevel());
Logger logger2 = Logger.getLogger("com.foo.bar");
resp.getWriter().println(logger2.getLevel());
resp.getWriter().println(configRan);
logger2.severe("not null");
logger2.severe((String)null);
}
}
示例2: processLog
import com.google.appengine.api.log.RequestLogs; //导入方法依赖的package包/类
@Override
public void processLog(RequestLogs log) {
List<AppLogLine> logLines = log.getAppLogLines();
if ( logLines == null || logLines.size() <= 0 )
return;
List<AppLogLineEntity> appLogs = new ArrayList<AppLogLineEntity>();
LogLevel lvl = LogLevel.DEBUG;
for (AppLogLine logLine : logLines )
{
if ( LEVEL_PRIORITY.get(lvl) < LEVEL_PRIORITY.get(logLine.getLogLevel()) )
{
lvl = logLine.getLogLevel();
}
AppLogLineEntity ent = new AppLogLineEntity();
ent.setLogLevel(LEVEL_PRIORITY_NAME.get(lvl));
ent.setLogMessage(logLine.getLogMessage());
ent.setTimeUsec(logLine.getTimeUsec());
appLogs.add(ent);
}
level = LEVEL_PRIORITY_NAME.get(lvl);
logs = new Gson().toJson(appLogs);
}
示例3: testLogLinesAreReturnedInSameOrderAsTheyAreLogged
import com.google.appengine.api.log.RequestLogs; //导入方法依赖的package包/类
@Test
public void testLogLinesAreReturnedInSameOrderAsTheyAreLogged() {
String logMark = getTimeStampRandom();
String msg1 = "msg 1 " + logMark;
String msg2 = "msg 2 " + logMark;
log.log(Level.INFO, msg1);
log.log(Level.INFO, msg2);
flush(log);
sync(15000);
RequestLogs requestLogs = getCurrentRequestLogs();
Integer msg1Index = null;
Integer msg2Index = null;
int i = 0;
for (AppLogLine appLogLine : requestLogs.getAppLogLines()) {
if (appLogLine.getLogMessage().contains(msg1)) {
msg1Index = i;
} else if (appLogLine.getLogMessage().contains(msg2)) {
msg2Index = i;
}
i++;
}
assertNotNull("1st log message not found in appLogLines", msg1Index);
assertNotNull("2nd log message not found in appLogLines", msg2Index);
assertTrue("Expected first logged message to come before second logged message", msg1Index < msg2Index);
}
示例4: getErrorLogs
import com.google.appengine.api.log.RequestLogs; //导入方法依赖的package包/类
private List<AppLogLine> getErrorLogs() {
LogService logService = LogServiceFactory.getLogService();
long endTime = new Date().getTime();
// Sets the range to 6 minutes to slightly overlap the 5 minute email timer
long queryRange = 1000 * 60 * 6;
long startTime = endTime - queryRange;
LogQuery q = LogQuery.Builder.withDefaults()
.includeAppLogs(true)
.startTimeMillis(startTime)
.endTimeMillis(endTime)
.minLogLevel(LogLevel.ERROR);
Iterable<RequestLogs> logs = logService.fetch(q);
List<AppLogLine> errorLogs = new ArrayList<>();
for (RequestLogs requestLogs : logs) {
List<AppLogLine> logList = requestLogs.getAppLogLines();
for (AppLogLine currentLog : logList) {
LogLevel logLevel = currentLog.getLogLevel();
if (LogLevel.FATAL == logLevel || LogLevel.ERROR == logLevel) {
errorLogs.add(currentLog);
}
}
}
return errorLogs;
}
示例5: fetchLogs
import com.google.appengine.api.log.RequestLogs; //导入方法依赖的package包/类
/**
* Retrieves logs using the query.
* @return logs fetched from server.
*/
public List<AppLogLine> fetchLogs(AdminLogQuery query) {
List<AppLogLine> logs = new LinkedList<>();
//fetch request log
Iterable<RequestLogs> records = LogServiceFactory.getLogService().fetch(query.getQuery());
for (RequestLogs record : records) {
//fetch application log
List<AppLogLine> appLogLines = record.getAppLogLines();
logs.addAll(appLogLines);
}
return logs;
}
示例6: doGet
import com.google.appengine.api.log.RequestLogs; //导入方法依赖的package包/类
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
resp.setContentType("text/plain");
PrintWriter writer = resp.getWriter();
boolean applogs = true;
if ("false".equals(req.getParameter("applogs"))) {
applogs = false;
}
boolean combined = false;
if ("true".equals(req.getParameter("combined"))) {
combined = true;
}
LogQuery query = LogQuery.Builder.withIncludeAppLogs(true).includeIncomplete(true);
for (RequestLogs record : LogServiceFactory.getLogService().fetch(query)) {
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(record.getStartTimeUsec() / 1000);
writer.println(String.format("\nDate: %s", cal.getTime().toString()));
if (combined) {
writer.println("COMBINED:" + record.getCombined());
} else {
writer.println("URL: " + record.getResource());
writer.println("");
}
if (applogs) {
List<AppLogLine> appLogs = record.getAppLogLines();
for (AppLogLine appLog : appLogs) {
writer.println("[" + appLog.getLogLevel() + "] " + appLog.getLogMessage());
}
}
}
}
示例7: doGet
import com.google.appengine.api.log.RequestLogs; //导入方法依赖的package包/类
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
resp.setContentType("text/plain");
String exporterSetClassStr = AnalysisUtility.extractParameterOrThrow(req, AnalysisConstants.BIGQUERY_FIELD_EXPORTER_SET_PARAM);
String minuteHistoryStr = AnalysisUtility.extractParameterOrThrow(req, AnalysisConstants.MINUTES_HISTORY_PARAM);
BigqueryFieldExporterSet exporterSet = AnalysisUtility.instantiateExporterSet(exporterSetClassStr);
LogService ls = LogServiceFactory.getLogService();
LogQuery lq = new LogQuery();
int minutesHistory = Integer.parseInt(minuteHistoryStr);
long currMillis = System.currentTimeMillis();
lq = lq.startTimeUsec((currMillis - minutesHistory * 60 * 1000) * 1000)
.endTimeUsec(currMillis * 1000)
.includeAppLogs(true);
List<String> appVersions = exporterSet.applicationVersionsToExport();
if (appVersions != null) {
lq = lq.majorVersionIds(appVersions);
}
Iterable<RequestLogs> logs = ls.fetch(lq);
for (RequestLogs rl : logs) {
resp.getWriter().println(rl.getCombined());
for (AppLogLine line : rl.getAppLogLines()) {
resp.getWriter().print("\t");
resp.getWriter().println(line.getLogMessage());
}
resp.getWriter().println();
}
}
示例8: findLogLine
import com.google.appengine.api.log.RequestLogs; //导入方法依赖的package包/类
protected AppLogLine findLogLine(String text, LogQuery logQuery) {
Iterable<RequestLogs> iterable = LogServiceFactory.getLogService().fetch(logQuery);
for (RequestLogs logs : iterable) {
for (AppLogLine logLine : logs.getAppLogLines()) {
if (logLine.getLogMessage().contains(text)) {
return logLine;
}
}
}
return null;
}
示例9: doGet
import com.google.appengine.api.log.RequestLogs; //导入方法依赖的package包/类
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
resp.setContentType("text/html");
PrintWriter writer = resp.getWriter();
writer.println("<!DOCTYPE html>");
writer.println("<meta charset=\"utf-8\">");
writer.println("<title>App Engine Logs Sample</title>");
// We use this to break out of our iteration loop, limiting record
// display to 5 request logs at a time.
int limit = 5;
// This retrieves the offset from the Next link upon user click.
String offset = req.getParameter("offset");
// We want the App logs for each request log
LogQuery query = LogQuery.Builder.withDefaults();
query.includeAppLogs(true);
// Set the offset value retrieved from the Next link click.
if (offset != null) {
query.offset(offset);
}
// This gets filled from the last request log in the iteration
String lastOffset = null;
int count = 0;
// Display a few properties of each request log.
for (RequestLogs record : LogServiceFactory.getLogService().fetch(query)) {
writer.println("<br>REQUEST LOG <br>");
DateTime reqTime = new DateTime(record.getStartTimeUsec() / 1000);
writer.println("IP: " + record.getIp() + "<br>");
writer.println("Method: " + record.getMethod() + "<br>");
writer.println("Resource " + record.getResource() + "<br>");
writer.println(String.format("<br>Date: %s", reqTime.toString()));
lastOffset = record.getOffset();
// Display all the app logs for each request log.
for (AppLogLine appLog : record.getAppLogLines()) {
writer.println("<br>" + "APPLICATION LOG" + "<br>");
DateTime appTime = new DateTime(appLog.getTimeUsec() / 1000);
writer.println(String.format("<br>Date: %s", appTime.toString()));
writer.println("<br>Level: " + appLog.getLogLevel() + "<br>");
writer.println("Message: " + appLog.getLogMessage() + "<br> <br>");
}
if (++count >= limit) {
break;
}
}
// When the user clicks this link, the offset is processed in the
// GET handler and used to cycle through to the next 5 request logs.
writer.println(String.format("<br><a href=\"/?offset=%s\">Next</a>", lastOffset));
}
示例10: doGet
import com.google.appengine.api.log.RequestLogs; //导入方法依赖的package包/类
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
resp.setContentType("text/html");
PrintWriter writer = resp.getWriter();
writer.println("<!DOCTYPE html>");
writer.println("<meta charset=\"utf-8\">");
writer.println("<title>App Engine Logs Sample</title>");
// We use this to break out of our iteration loop, limiting record
// display to 5 request logs at a time.
int limit = 5;
// This retrieves the offset from the Next link upon user click.
String offset = req.getParameter("offset");
// We want the App logs for each request log
LogQuery query = LogQuery.Builder.withDefaults();
query.includeAppLogs(true);
// Set the offset value retrieved from the Next link click.
if (offset != null) {
query.offset(offset);
}
// This gets filled from the last request log in the iteration
String lastOffset = null;
int count = 0;
// Display a few properties of each request log.
for (RequestLogs record : LogServiceFactory.getLogService().fetch(query)) {
writer.println("<br>REQUEST LOG <br>");
DateTime reqTime = new DateTime(record.getStartTimeUsec() / 1000);
writer.println("IP: " + record.getIp() + "<br>");
writer.println("Method: " + record.getMethod() + "<br>");
writer.println("Resource " + record.getResource() + "<br>");
writer.println(String.format("<br>Date: %s", reqTime.toString()));
lastOffset = record.getOffset();
// Display all the app logs for each request log.
for (AppLogLine appLog : record.getAppLogLines()) {
writer.println("<br>" + "APPLICATION LOG" + "<br>");
DateTime appTime = new DateTime(appLog.getTimeUsec() / 1000);
writer.println(String.format("<br>Date: %s", appTime.toString()));
writer.println("<br>Level: " + appLog.getLogLevel() + "<br>");
writer.println("Message: " + appLog.getLogMessage() + "<br> <br>");
}
if (++count >= limit) {
break;
}
}
// When the user clicks this link, the offset is processed in the
// GET handler and used to cycle through to the next 5 request logs.
writer.println(String.format("<br><a href=\"/?offset=%s\">Next</a>", lastOffset));
}
示例11: processLog
import com.google.appengine.api.log.RequestLogs; //导入方法依赖的package包/类
@Override
public void processLog(RequestLogs log) {
logIndex = -1;
// Usually there are multiple app logs.
List<AppLogLine> logLines = log.getAppLogLines();
if ( logLines == null || logLines.size() <= 0 )
return;
if ( logs.size() > 0 )
logs.clear();
for ( AppLogLine logLine : logLines )
{
String logMsg = logLine.getLogMessage();
if ( logMsg == null || logMsg.isEmpty() )
continue;
if ( logLine.getLogLevel() != LogLevel.INFO )
continue;
String [] msgs = logLine.getLogMessage().split("^.*AppLog" + LOG_DELIMETER);
// If Log Parsing result is not valid, pass log data
if ( msgs.length != 2 )
continue;
String msg = msgs[1];
try
{
JSONObject data = new JSONObject( msg );
if ( !data.has("type") )
continue;
if ( !data.getString("type").equals(typeName))
continue;
} catch (JSONException e)
{
continue;
}
logs.add( msg );
}
}