Scripting to read gateway logs

Ahh, that does the trick.

Code for prosperity

from com.inductiveautomation.ignition.gateway import IgnitionGateway
from com.inductiveautomation.ignition.common.logging import LogQueryConfig
	
loggingManager = IgnitionGateway.get().getLoggingManager()
	
queryFilter = LogQueryConfig.newBuilder().build()
	
logResults = loggingManager.queryLogEvents(queryFilter)
	
events = logResults.getEvents()
	
system.perspective.print(events)

I did notice this documentation error for the LogQueryConfig it states the following:

A set of parameters for querying the logging system. Can be created by hand, or with LogQueryConfigBuilder.newBuilder() (the preferred method)

But it seems that the newBuilder method isn't valid for LogQueryConfigBuilder, instead it should be LogQueryConfig.newBuilder()

5 Likes