Döcu Content

NotesLog Data Conversion JavaScript/Xpages

TXT File to Browser


Throw NotesLog Errors to your Browser as TXT file to be picked up by Apps and complete troubleshooting, fixing items for your users; item that can be used to compare current or older App errors against researched efforts rendred/time spent by developers on the Internet, help save time and effort buidling systems.


Information contained in the following is presented as is. This tutorial assumes you have basic Lotus Notes Configuration knowledge, and are familiar with Google products.

Create TXT File to Browser

Use below JavaAgent to create a TXT file to your browser out of NotesLog data, you could add an alias with a .txt extension to facilitate picking it up elsewhere in your App, or run as main JavaAgent naming convention.

Here are the Steps, see screenshots for areas of interest

  1. Grab a copy of the code below and pop it into your App

  2. Change search Strings in code to match items in your current NotesLogs

  3. Modify your Agent Properties to reflect a certain alias name, with a .txt extension

  4. Run: http://localhost/docucontent.nsf/javaagentnoteslogcsvdataforsites.txt in your Browser

  5. javaagentnoteslogcsvdataforsites.txt being the alias name in Agent Properties

  6. Wait a couple of minutes, perhaps more depending on error length in NotesLog

Copy and Paste JavaAgent



* Created: 2014.

* NotesLogEventListProcessing

* NotesLog items to be converted to TXT/CSV/XML data for Xpages


import lotus.domino.*;

import java.io.PrintWriter;

import java.util.*;


* @author Dököll Solutions, Inc.

* @version 2014.



public class JavaAgent extends AgentBase {

//TODO: Create TXT, CSV, and XML files with the results, feed to Xpages

public void NotesMain() {

try {

//Grab session, yank database out of that

Session session = getSession();

System.out.println("FOUND_SESSION " + session);

Database database = session.getDatabase("", "log.nsf");

System.out.println("FOUND_DATABASE " + session);

//DateTime dtToday = session.createDateTime("Today");

// PrintWriter...

PrintWriter pw = getAgentOutput();

// Content type set at Txt

// TODO: Figure out a better version to load a CSV file to browser

// currently, the csv downloads to local directory


String dtToday = ("01/12/2014");

System.out.println("FOUND_DATE " + dtToday);

//Convert this date to String, endsWith or startsWith can't search therefore

String ConvertDateToString = dtToday.toString();

System.out.println("FOUND_DATE_CONVERSION " + ConvertDateToString);

//Fetch EventList through Forms, by pass the MiscEvents view

//TODO: Grab EventList View if you need specific dates

DocumentCollection docColl = database.search("Form = 'Events'");

Document logDoc = docColl.getFirstDocument();

System.out.println("BEGIN LOOP...");

//Enter Loop, we are looking at only todays docs/Events

System.out.println("BEGIN LOOP...");

while (logDoc != null) {

// Grab EventList items

//System.out.println("Grabbing EventList items...");

Vector itemsList = logDoc.getItemValue("EventList");

//Run through Events line by line

for (Enumeration values = itemsList.elements(); values

.hasMoreElements();) {

String eventFetch = (String) values.nextElement();

if (eventFetch.startsWith(ConvertDateToString)

&& eventFetch.endsWith("Anonymous")) {

eventFetch = eventFetch.substring(0, eventFetch.indexOf("Anonymous"));

//TODO: Perhaps begin conversion to XML and so on here...

// write records from view into a Text file and show it in the

// browser


//System.out.println("FOUND_LOG " + eventFetch);



//grab additional log items, as necessary...

logDoc = docColl.getNextDocument();


} catch (Exception e) {



}//end of program...


Configure Agent Properties

Run to Browser as TXT

Be sure to remove Sytem.outs to avoid adding your reesults to Log.nsf


You can now reference grab NotesLog data and throw to your Browser as a converted TXT file; information that can be used to help you better troubleshoot and find errros about your Apps.

Questions, comments, please post a brief message on our Contact form on the main site.

Thank you for coming...