Disable log in test katalon

Hi,

I want to disable logging during data loading so that it does not write anything while performing certain operations, but it is dropping me this error since updating katalon to 8.1.0

I have this:

KeywordLogger log = new KeywordLogger()
log.logger.setLevel(Level.OFF)

And the error that I get when running the test is the following

groovy.lang.MissingMethodException: No signature of method: ch.qos.logback.classic.Logger.setLevel() is applicable for argument types: (java.util.logging.Level) values: [OFF]
Possible solutions: setLevel(ch.qos.logback.classic.Level), getLevel()

Can you help me? Thank you so much.

Cheers.

Which log messages do you want to suppress? Show us a screenshot, and tell us: “I want to suppress this => xxxx”.

I ask this because there are 2 types of logging systems working in Katalon Studio, and these have different settings.

1 Like

Good Morning,

We read the data to launch the tests from an excel file. We do not want to show this operation in the log, the reading of the data. we use Keywordlogger to access the log.

I want to supress this:

//We disable the log during data loading
KeywordLogger log = new KeywordLogger()
log.logger.setLevel(Level.OFF)

GlobalVariable.datosTest = new LinkedHashMap<String, TestEntidad>()
setDatosTest(excelCampos, GlobalVariable.datosTest, evaluator)

//We activate the log again
log.logger.setLevel(Level.INFO)

WebUI.comment(‘Data uploaded completed’)

This is the complete error when debugging

2021-10-27 09:31:23.115 WARN c.k.katalon.core.logging.KeywordLogger - Please use “KeywordUtil.logInfo()” instead of “new KeywordLogger()” constructor. “KeywordLogger” is an internal API and might be changed in the future.
2021-10-27 09:31:23.115 DEBUG testcase.RellenarDatos - 6: logger.setLevel(OFF)
2021-10-27 09:31:23.154 ERROR c.k.katalon.core.main.TestCaseExecutor - :x: Test Cases/Entidades/RellenarDatos FAILED.
Reason:
groovy.lang.MissingMethodException: No signature of method: ch.qos.logback.classic.Logger.setLevel() is applicable for argument types: (java.util.logging.Level) values: [OFF]
Possible solutions: setLevel(ch.qos.logback.classic.Level), getLevel()
at RellenarDatos.run(RellenarDatos:39)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:430)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:421)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:400)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:392)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:273)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:142)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:133)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1635319874820.run(TempTestCase1635319874820.groovy:25)

2021-10-27 09:31:23.165 ERROR c.k.katalon.core.main.TestCaseExecutor - :x: Test Cases/Entidades/RellenarDatos FAILED.
Reason:
groovy.lang.MissingMethodException: No signature of method: ch.qos.logback.classic.Logger.setLevel() is applicable for argument types: (java.util.logging.Level) values: [OFF]
Possible solutions: setLevel(ch.qos.logback.classic.Level), getLevel()
at RellenarDatos.run(RellenarDatos:39)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:430)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:421)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:400)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:392)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:273)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:142)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:133)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1635319874820.run(TempTestCase1635319874820.groovy:25)

Thanks a lot.

It seems that what you call “this operation” is the single line in your script:

setDatosTest(excelCampos, GlobalVariable.datosTest, evaluator)

You haven’t showed the source code of the setDatosTest() function. You haven’t showed what sort of log messages are emitted by setDataosTest(). We know nothing about it. So it is difficult to say anything about it.

As this message tells you, you should not use KeywordLogger at all.

You shoud use KeywordUtil instead if you need to.


And also you have a coding mistake at

log.logger.setLevel(Level.OFF)

as the following message tells:

See the section titled “Logs Configuration” in the following Katalon Official document.

Katalon Studio uses SLF4J backed by LogBack. This section describes how to customise the SLF4J logging behavior.

If you refactor the setDataosTest functon to a new Groovy class (for example, “my.DataUtil”) in Keywords folder, then you would be able to control the log level of the “my.DataUtil” class by editing the Include/config/log.properties file.

If you write in the log.properties

logging.level.my.DataUtil=WARN

then the log level of “my.DataUtil” class is set WARN, then INFO & DEBUG messages through SLF4J+Logback from “my.DataUtil” class will be suppressed.

Your post is too difficult to read.

Please use Code Formatting for better code presentation.

Sorry,

import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import internal.GlobalVariable as GlobalVariable

import org.apache.poi.ss.usermodel.Cell as Cell
import org.apache.poi.ss.usermodel.Row as Row
import org.apache.poi.ss.usermodel.FormulaEvaluator as FormulaEvaluator
import org.apache.poi.xssf.usermodel.XSSFSheet as XSSFSheet
import org.apache.poi.xssf.usermodel.XSSFWorkbook as XSSFWorkbook
import org.apache.poi.xssf.usermodel.XSSFRow as XSSFRow
import org.apache.poi.ss.usermodel.WorkbookFactory as WorkbookFactory

import com.kms.katalon.core.logging.KeywordLogger

import java.util.HashMap
import java.util.LinkedHashMap
import java.util.List
import java.util.logging.Level
import java.util.logging.Logger

import static utilidades5.FuncionesExcel.*
import static utilidades5.FuncionesGestionFicheros.*
import utilidades5.entidades.TestEntidad as TestEntidad
import utilidades5.entidades.Validacion as Validacion
import utilidades5.entidades.Pestania
import utilidades5.entidades.Campo as Campo

//FileInputStream ficheroCampos = new FileInputStream(getPathDatosCompartidos('TestFiles5/' + getCarpetaCasos() + '/' + EXCELCASOPRUEBA + '.xlsx'))
FileInputStream ficheroCampos = new FileInputStream('C:/proyectos/DatosCompartidos/TestFiles5pre/CasosPruebaProcesos/FSN_EMITIR_PROCESO.xlsx')

XSSFWorkbook excelCampos = new XSSFWorkbook(ficheroCampos)

FormulaEvaluator evaluator = excelCampos.getCreationHelper().createFormulaEvaluator()

WebUI.comment('Iniciando carga de datos...')

//Desactivamos el log durante la carga de datos
KeywordLogger log = new KeywordLogger()
log.logger.setLevel(Level.OFF)

GlobalVariable.datosTest = new LinkedHashMap<String, TestEntidad>()
setDatosTest(excelCampos, GlobalVariable.datosTest, evaluator)

//Activamos de nuevo el log
log.logger.setLevel(Level.INFO)

WebUI.comment('Carga de datos finalizada')

/*---------------------------------------------------------------------------------------------------------------------------------------------*/

private String getCarpetaCasos() {
	switch (TIPOENTIDAD) {
		case 'Abono':
		case 'Factura':
			return 'CasosPruebaFacturas'
		case 'Pedido':
		case 'Vale':
			return 'CasosPruebaPedidos'
		case 'ProveedorAplicacion':
		case 'Proveedor':
			return 'CasosPruebaProveedores'
		case 'Solicitud':
			return 'CasosPruebaSolicitudes'
		case 'Proceso':
			return 'CasosPruebaProcesos'
	}
}

private void setDatosTest(XSSFWorkbook excelCampos, LinkedHashMap<String, TestEntidad> test, FormulaEvaluator evaluator) {
	getTestFromExcel(excelCampos.getSheetAt(0), test)
	
	for (int i = 1; i < excelCampos.getNumberOfSheets(); i++) {
		XSSFSheet pestania = excelCampos.getSheetAt(i)
		
		switch (pestania.getSheetName()) {
			case 'Datos':
				break
			case 'Validaciones':
				getValidacionesFromExcel(pestania, test)
				break
			case 'ValidacionesLineas':
				getValidacionesLineasFromExcel(pestania, test)
				break
			case 'Notificaciones':
				getNotificacionesFromExcel(pestania, test)
				break
			case 'Filtros':
				getFiltrosFromExcel(pestania, test)
				break
			case 'Proceso':
				getCamposPestaniaProcesoFromExcel(pestania, test, evaluator)
				break
			default:
				getCamposPestaniaFromExcel(pestania, test, evaluator)
				break
		}
	}
}

private void getTestFromExcel(XSSFSheet pestaniaTest, LinkedHashMap<String, TestEntidad> test) {
	for (int numFila = 1; numFila <= pestaniaTest.getLastRowNum(); numFila++) {
		XSSFRow fila = pestaniaTest.getRow(numFila)
		String nombreTest = getValorCelda(fila.getCell(1))
		TestEntidad testEntidad = new TestEntidad(getValorCelda(fila.getCell(0)), getValorCelda(fila.getCell(1)), getValorCelda(fila.getCell(2, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL)), getValorCelda(fila.getCell(3, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL)), getValorCelda(fila.getCell(4, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL)), getValorCelda(fila.getCell(5, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL)), getValorCelda(fila.getCell(6, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL)), getValorCelda(fila.getCell(7)))
		testEntidad.setEntidad(TIPOENTIDAD, getValorCelda(fila.getCell(8, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL)))
		test.put(nombreTest, testEntidad)
	}
	
	List<TestEntidad> testList = new ArrayList<String>(test.values());
	for (int i = 0; i < testList.size(); i++) {
		if (i == testList.size() - 1) {
			testList.get(i).setCerrarSesion(true)
		} else {
			if (testList.get(i + 1).getUrl() == null) {
				testList.get(i).setCerrarSesion(false)
			} else {
				testList.get(i).setCerrarSesion(true)
			}
		}
		testList.get(i).setCerrarSesionPorTipo(TIPOENTIDAD)
		testList.get(i).setCerrarSesionPorAccion()
	}
}

private void getValidacionesFromExcel(XSSFSheet pestaniaValidaciones, LinkedHashMap<String, TestEntidad> test) {
	for (int numFila = 1; numFila <= pestaniaValidaciones.getLastRowNum(); numFila++) {
		XSSFRow fila = pestaniaValidaciones.getRow(numFila)
		String nombreTest = getValorCelda(fila.getCell(0))
		String accionTest = getValorCelda(fila.getCell(1))
		Validacion validacion = new Validacion(getValorCelda(fila.getCell(2)), getValorCelda(fila.getCell(3, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL)), getValorCelda(fila.getCell(4, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL)), getValorCelda(fila.getCell(5, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL)))
		TestEntidad testEntidad = test.get(nombreTest)
		if (testEntidad != null) {
			testEntidad.setValidacionTipo(accionTest, validacion)
		}
	}
}

private void getValidacionesLineasFromExcel(XSSFSheet pestaniaValidacionesLineas, LinkedHashMap<String, TestEntidad> test) {
	int numColumnas = pestaniaValidacionesLineas.getRow(0).lastCellNum
	for (int numFila = 1; numFila <= pestaniaValidacionesLineas.getLastRowNum(); numFila++) {
		XSSFRow fila = pestaniaValidacionesLineas.getRow(numFila)
		String nombreTest = getValorCelda(fila.getCell(0))
		String grupo = numColumnas == 9 ? null : getValorCelda(fila.getCell(1, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL))
		String pestania = getValorCelda(fila.getCell(grupo == null ? 1 : 2)).equals('Principal') ? '%PRINCIPAL%' : getValorCelda(fila.getCell(2))
		String grid = getValorCelda(fila.getCell(grupo == null ? 2 : 3))
		String linea = getValorCelda(fila.getCell(grupo == null ? 3 : 4, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL))
		String detalle = getValorCelda(fila.getCell(grupo == null ? 4 : 5, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL))
		Validacion validacion = new Validacion(getValorCelda(fila.getCell(grupo == null ? 5 : 6)), getValorCelda(fila.getCell(grupo == null ? 6 : 7, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL)), getValorCelda(fila.getCell(grupo == null ? 7 : 8, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL)), getValorCelda(fila.getCell(grupo == null ? 8 : 9, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL)))
		TestEntidad testEntidad = test.get(nombreTest)
		if (testEntidad != null) {
			if (grupo == null) {
				if (linea != null) {
					testEntidad.getCabecera().getPestania(pestania).setValidacionLinea(grid, linea, detalle, validacion)
				} else {
					testEntidad.getCabecera().getPestania(pestania).setValidacionGrid(grid, validacion)
				}
			} else {
				if (linea != null) {
					testEntidad.getGrupo(grupo).getPestania(pestania).setValidacionLinea(grid, linea, detalle, validacion)
				} else {
					testEntidad.getGrupo(grupo).getPestania(pestania).setValidacionGrid(grid, validacion)
				}
			}
		}
	}
}

private void getCamposPestaniaFromExcel(XSSFSheet pestaniaExcel, LinkedHashMap<String, TestEntidad> test, FormulaEvaluator evaluator) {
	String nombrePestania = pestaniaExcel.getSheetName().equals('Principal') ? '%PRINCIPAL%' : pestaniaExcel.getSheetName()
	for (int numFila = 1; numFila <= pestaniaExcel.getLastRowNum(); numFila++) {
		XSSFRow fila = pestaniaExcel.getRow(numFila)
		String nombreTest = getValorCelda(fila.getCell(0))
		TestEntidad testEntidad = test.get(nombreTest)
		if (testEntidad != null) {
			String grid = getValorCelda(fila.getCell(1, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL))
			Campo campo = new Campo(getValorCelda(fila.getCell(4, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL)), getValorCelda(fila.getCell(5, Row.CREATE_NULL_AS_BLANK), evaluator), getValorCelda(fila.getCell(6, Row.CREATE_NULL_AS_BLANK), evaluator), getValorCelda(fila.getCell(7)), getValorCelda(fila.getCell(8)))
			if (grid != null) {
				String numLinea = getValorCelda(fila.getCell(2))
				String detalle = getValorCelda(fila.getCell(3, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL))
				if (nombrePestania.equals('%PRINCIPAL%')) {
					testEntidad.getCabecera().setLineaGrid(grid, numLinea, detalle, campo)
				} else {
					testEntidad.getCabecera().getPestania(nombrePestania).setLineaGrid(grid, numLinea, detalle, campo)
				}
			} else {
				if (nombrePestania.equals('%PRINCIPAL%')) {
					testEntidad.getCabecera().setCampo(campo)
				} else {
					testEntidad.getCabecera().getPestania(nombrePestania).setCampo(campo)
				}
			}
		}
	}
}

private void getCamposPestaniaProcesoFromExcel(XSSFSheet pestaniaExcel, LinkedHashMap<String, TestEntidad> test, FormulaEvaluator evaluator) {
	for (int numFila = 1; numFila <= pestaniaExcel.getLastRowNum(); numFila++) {
		XSSFRow fila = pestaniaExcel.getRow(numFila)
		String nombreTest = getValorCelda(fila.getCell(0))
		TestEntidad testEntidad = test.get(nombreTest)
		if (testEntidad != null) {
			String grupo = getValorCelda(fila.getCell(1, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL))
			String pestania = getValorCelda(fila.getCell(2, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL))
			String grid = getValorCelda(fila.getCell(3, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL))
			String numLinea = getValorCelda(fila.getCell(4))
			String detalle = getValorCelda(fila.getCell(5, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL))
			Campo campo = new Campo(getValorCelda(fila.getCell(6, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL)), getValorCelda(fila.getCell(7, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK), evaluator), getValorCelda(fila.getCell(8, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK), evaluator), getValorCelda(fila.getCell(9)), getValorCelda(fila.getCell(10)))
			if (grupo == null) {
				if (pestania == null) {
					if (grid != null) {
						testEntidad.getCabecera().setLineaGrid(grid, numLinea, detalle, campo)
					} else {
						testEntidad.getCabecera().setCampo(campo)
					}
				} else {
					if (grid != null) {
						testEntidad.getCabecera().getPestania(pestania).setLineaGrid(grid, numLinea, detalle, campo)
					} else {
						testEntidad.getCabecera().getPestania(pestania).setCampo(campo)
					}
				}
			} else {
				if (pestania != null) {
					if (grid != null) {
						testEntidad.getGrupo(grupo).getPestania(pestania).setLineaGrid(grid, numLinea, detalle, campo)
					} else {
						testEntidad.getGrupo(grupo).getPestania(pestania).setCampo(campo)
					}
				} else {
					testEntidad.getGrupo(grupo).setCampo(campo)
				}
			}
		}
	}
}

private void getNotificacionesFromExcel(XSSFSheet pestaniaValidaciones, LinkedHashMap<String, TestEntidad> test) {
	for (int numFila = 1; numFila <= pestaniaValidaciones.getLastRowNum(); numFila++) {
		XSSFRow fila = pestaniaValidaciones.getRow(numFila)
		String nombreTest = getValorCelda(fila.getCell(0))
		TestEntidad testEntidad = test.get(nombreTest)
		if (testEntidad != null) {
			testEntidad.setMarcadorNotificacion(getValorCelda(fila.getCell(1)), getValorCelda(fila.getCell(2)), getValorCelda(fila.getCell(3, Row.CREATE_NULL_AS_BLANK)))
		}
	}
}

private void getFiltrosFromExcel(XSSFSheet pestaniaFiltros, LinkedHashMap<String, TestEntidad> test) {
	for (int numFila = 1; numFila <= pestaniaFiltros.getLastRowNum(); numFila++) {
		XSSFRow fila = pestaniaFiltros.getRow(numFila)
		String nombreTest = getValorCelda(fila.getCell(0))
		TestEntidad testEntidad = test.get(nombreTest)
		if (testEntidad != null) {
			Campo campo = new Campo(getValorCelda(fila.getCell(1)), getValorCelda(fila.getCell(2, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK)), getValorCelda(fila.getCell(3, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL)))
			testEntidad.setFiltro(campo)
		}
	} 
}

you have a coding mistake at

log.logger.setLevel(Level.OFF)

as the following error message tells:

You shouldn’t do this at all.

As I wrote, See the section titled “Logs Configuration” in the following Katalon Official document.

https://docs.katalon.com – 26 Oct 21

View and Customize Execution Log

Viewing the execution log is the very first approach when troubleshooting automation test execution. The critical information in the log can quickly help project teams pinpoint the root causes of…

thanks so much @kazurayam, i’ll try

Before we had katalon 5.8 and everything worked fine, but we updated to 8.1 and then everything started to fail.

Will you go back to v5.8?

does not let new users login to version 5.8 freezes. I read that it was only possible until April 2020 hahahaha

Good morning,

I have gotten it to work. I had to comment on the code referring to the log and add in log properties: logging.level.testcase = INFO