Leave feedback
  • Featured

    Log to database

Write an Article
Saturday 03 November, 2012
Stefan Cohen Stefan Cohen StreamServe Employee Administrator
6 likes 4427 views

This article is about configuring and using a database log in StreamServe. A StreamServer log file is usually written to a log file. A little known feature is the possibly to log to a database.

The StreamServe Service Component Framework (SCF) provides a shared log service. This log service is used by all StreamServe applications and provides a common logging interface for the applications. The log service has a couple of log providers. When monitoring a StreamServer log in in Control Center, you see one of them in action. Another Log provider is writing log files to disk (the log.txt file is the rusult of the file system provider). A third provider is the database provider and that is the focus of this article.

The benefit of logging to the database is that you can query only the information you are interested. in. 

To endable database logging for an application, go tho the app in Control Center and right-click on the application. Next, select "Log configuration". This will bring up the Log configuraiton dialog. In the dialog, set the Database logging parameter to "Enabled". Close the dialog and restart the application.

This will enable the database log provider for the selected applicaiton. Now we need to fill the database with something to report. Submit a couple of jobs to the StreamServer and wait for them to finish. 

The log entries will now be written to the runtime database of the selected application rather than to the log.txt file.

The log can now be queried using web service requests against the Service Gateway. To try it, you first need to create a Service Gateway application in you applicaiton domain using control center. Once created, simply start the the SGW.

We provide a commandline client to query the log service. this client is called LogWebServiceClient.exe on windows and can be found in: <instllpath>\OpenText\StreamServe\Platform\Core\1.5\bin

The help for the client looks like this:

Usage C:\Program Files (x86)\OpenText\StreamServe\Platform\Core\1.5\bin\LogWebServiceClient.exe

Required arguments:
-------------------
-action <action> Can be one of getlograw. Requires argument -numlines
-file <path> Filename where the result will be written

Dependent arguments
-------------------
-numlines <num> Number of lines to return (tail). Default is 200
-starttime <ISO8601 time> Start time.
-endtime <ISO8601 time> End time.
-toplevel <toplevel> Log toplevel.
-threadid <id> Thread id. Only return logs created by this threadid. This should be used with -jobid.
-jobid <id> jobid
-sender <name> Name of sender
-receiver <name> Name of receiver
-extjobid <id> External jobid
-applicationid <id> Applicationid
-fromloglevel <level> Return entries with loglevels from
-tologlevel <level> Return entries with loglevels to
-msginfo <msginfo> What type of metadata to return, can be one of or combination of
1 = timestamp
2 = logid
4 = loglevel
8 = applicationid
16 = userid
32 = threadid
64 = jobid
128 = sourceid
256 = toplevel
512 = year
1024 = external jobid
2048 = receiver
-1 = all
Example: 2 + 4 + 16 = 22 will return logid + loglevel + userid + message
Default is 1 + 2 = timestamp + logid + message
-stdout Print log to stdout
-applogid Get logmessages with id > applogid, default is 1

Optional arguments:
-------------------
-endpoint <url> Default is http://localhost:2718
-v Output version information and exit
-h Display this help and exit

--------------------
Example, fetching the latest 10 rows for an application and print it to stdout
LogWebServiceClient.exe -action getlograw -numlines 10 -msginfo 7 -applicationid <id> -stdout

Other examples:

#dump the latest 200 lines to the file mylog.log
LogWebServiceClient.exe -action getlograw -file mylog.log

#dump all log attributes from the last 200 lines to stdout
LogWebServiceClient.exe -action getlograw -msginfo -1 -stdout

#dump the timestamp, logid and log level for the specified applicaiton from the last 10 lines to stdout
LogWebServiceClient.exe -action getlograw -numlines 10 -msginfo 7 -applicationid 87F3FC4D-AA58-4834-ADCC-46565F01DE66 -stdout

All the logs for all applications are written to the same database. this makes it possible to track the logs for jobs that are processed by multiple applciations within a domain. 

To see jobs from a specific applciaiton, you must use the -applicationid argument

The application id must be properly set. StreamServe Application IDs looks like GUIDs. Ex: 87F3FC4D-AA58-4834-ADCC-46565F01DE66
In Windows, an easy way to get an application ID is to go to services in the control panel and select properties for the service where you want to get the log from. The Applciation ID is the same as the Service Name. Another way to get the App ID is thru the applications table in the StrsSER database.

The application id must be properly set. StreamServe Application IDs looks like GUIDs. Ex: 87F3FC4D-AA58-4834-ADCC-46565F01DE66
In Windows, an easy way to get an application ID is to go to services in the control panel and select properties for the service where you want to get the log from. The Applciation ID is the same as the Service Name. Another way to get the App ID is thru the applications table in the StrsSER database.

//Stefan

 

 

Comments (5)

  • Great stuff! Just to be curious ...which version is this from?

    Sunday 04 November, 2012 by Vyv Lomax
  • I think it was added in 5.4 but i need to check to be sure.

    //Stefan

    Sunday 04 November, 2012 by Stefan Cohen
  • It was added in SP3 :)

    /David

    Thursday 08 November, 2012 by David Svennevid
  • When will this log in the database been cleaned?

    And is there an other way to get the information out of the database. Is it one special table in the database which you can query?

     

    Sunday 11 November, 2012 by Pierre Schuurmans
  • The log is logged to table ApplicationLog, there is currently no out of the box cleaning of the table but "TRUNCATE TABLE ApplicationLog" or "DELETE FROM ApplicationLog WHERE LogDateTime < MyTimeThreshold" will do the job.

    /David

    Monday 12 November, 2012 by David Svennevid

   


Post comment