Checking the NRE log

If the app terminates unexpectedly or encounters an error while running in the user’s environment, a log file can be created for analysis and to check the problem.

The log function is supported in the NRE of Windows and macOS only.

Errors that occur when running the app before the log manager runs are not logged. When the app is launched, it is displayed to the user as an alert window.

Create log file settings

The create log file feature is not a default setting and requires additional setup. Log file creation settings can be set in Nexacro Studio or in a config file.

When the app is run, the settings in the config file are applied first. If there is a config file, the value set in the Environment item is ignored.

Create log file settings in Environment

The property values and log functions can be set in Nexacro Studio. Related property values can only be set in Nexacro Studio and cannot be changed while the app is running.

Setting log file creation in the tracemode property

Select Environment in Nexacro Studio and change the tracemode. If the default value is "none", the log function is not processed, and if the property value is set to "new" or "append", a log file is created.

Setting logging level and frequency

You can select Environment in Nexacro Studio and set the loglevel and traceduration properties. The loglevel property sets the situation for the logging and the traceduration property sets the cycle for log file creation.

Config file settings

The log feature can be set in the config file. The Environment property can be set without editing by copying the config file into the user's execution environment or by including it in the build.

Setting -NC options

The "-NC" option can be used when running the nexacro.exe file in the Windows operating system. The config file can be set in the same location as the nexacro.exe file to be run.

For example, if the location of the nexacro.exe file has specified the "log_config.xml" file as the warning -NC value as below, the "log_config.xml" file must exist in the same path.

C:\Program Files\TOBESOFT\Nexacro N\21\TEST_LOG\nexacro.exe
C:\Program Files\TOBESOFT\Nexacro N\21\TEST_LOG\log_config.xml

If the -NC option is not used, the nexacro_config.xml file will be searched for in the default path and it will be referred to if it exists.

Setting nexacro_config.xml file

For -NC option settings, a file name can be specified, but a separate option must be specified. The nexacro_config.xml file automatically recognizes and processes a file with a given name in the specified location when running the app.

Windows operating systems

In the Windows OS, the feature for distributing the apps by including the nexacro_config.xml file is not included. The nexacro_config.xml file can be created in the path below and referred to it when running the app.

%USERAPP%\Config\[Key]\nexacro_config.xml

[Key] is the -K option specified in the nexacro.exe execution option or the App Title specified in the Build App stage.

macOS operating systems

App Development and Execution (iOS/iPadOS - Xcode) > Set Config

nexacro_config.xml file properties

The configuration file (nexacro_config.xml) or the file specified with the -NC option is written in the format shown below.

<?xml version="1.0" encoding="UTF-8"?>
<nexacro-config os="windows">
	<application
		file-logging="true"
		loglevel="debug"
		tracemode="new"
		traceduration="-1"/>
	<log
		filepath="%USERAPP%\Log\nre_log_test.log"
		filesize="408960"
		backupfilecount="5"/>
</nexacro-config>

Among the properties specified in the nexacro_config.xml file, only those related to the log file creation are explained below.

Tags/Properties

Explanation

nexacro-config

os

This property sets the operating system.

- windows: Windows operating system

- Android: Android operating system

- osx: macOS operating system

application

file-logging

This property sets whether to save the initial loading error information.

This is the same as the information recorded in the nexacro_startError.log file in the %USERAPP% path

loglevel

This property sets the log output level.

fatal | error | warn | info | debug

Fatal, error, warn, and info are log information processed inside the framework. If the trace method is used or a script error occurs, it is processed as debug.

tracemode

This property sets how log files are processed.

new: delete the previous record and record a new log

append: record the log after the previous record

traceduration

This property sets options for creating daily log files.

The default value is -1.

log

filepath

This property sets the log file path and file name.

If no path is specified, the file is created in the path below.

- Windows: %USERAPP%

- Android: %SD_CARD%/Android/data/[package name]/files/nexacro/21/Log/

- macOS: %USERAPP%/Log


If the file name is not set, the file is created in the format shown below.

- nexacro_[protocol+url+port][bootstrapfilename].log

ex) nexacro_httplocalhost8080startjson.log

filesize

This property sets the maximum size of the log file.

The default value is 204,800 bytes.

If you set a value less than the default, the default is applied.

backupfilecount

This property sets the maximum number of the log files.

This is the number of files that can be left as backup when the log file size becomes larger than the filesize.

The default value is 1.

If the os property value is "windows", the filepath property value may cause security issues, so the following restrictions are applied.

Example of file creation by property

backupfilecount

If the size of the created log file exceeds the value of the filesize property, backup files are additionally created.

Create files by adding numbers to the end of the file names. When the value specified by the backupfilecount property is reached, the first created file is deleted and the log is recorded.

If the app runs every hour and records a 300KB log run, the log files are created as follows.

<log filepath="%USERAPP%nrelog.log" filesize="200" backupfilecount="3"/>

Log file name

File size

Time of file creation/change

Task order

2020/05/26 13:00

nrelog.log

100KB

2020/05/26 13:00

Final log

nrelog.log.1

200KB

2020/05/26 13:00

Start log

2020/05/26 14:00

nrelog.log

10KB

2020/05/26 14:00

Final log

nrelog.log.1

200KB

2020/05/26 14:00


nrelog.log.2

200KB

2020/05/26 14:00


nrelog.log.3

200KB

2020/05/26 13:00

Start log

2020/05/26 15:00

nrelog.log

180KB

2020/05/26 15:00

Final log

nrelog.log.1

200KB

2020/05/26 14:00


nrelog.log.2

200KB

2020/05/26 14:00


nrelog.log.3

200KB

2020/05/26 15:00

Start log / roll over

traceduration

Based on the date of log file creation, files created before the value of the traceduration property are deleted.

A file is created and the date ("_yyyymmdd") is added to the end of the file name. Date comparison is processed according to the operating system system time.

If the app is run once a day and not on weekends, log files are created and deleted as follows. Since the app is not run on weekends (Saturday and Sunday), previously created log files are not deleted. When the app is run on Monday, log files before the traceduration property value are deleted.

<nexacro-config os="windows">
	<application file-logging="true" quiet="false" loglevel="debug" tracemode="new" traceduration="2"/>
	<log filepath="%USERAPP%nrelog.log" filesize="408960" backupfilecount="3"/>
</nexacro-config>

Log file name

Date of file creation

Task

2020/05/21 (Thursday)

nrelog_20200521.log

2020/05/21

Create file

2020/05/22 (Friday)

nrelog_20200521.log

2020/05/21

Maintain

nrelog_20200522.log

2020/05/22

Create file

2020/05/23 (Saturday)

nrelog_20200521.log

2020/05/21

Maintain

nrelog_20200522.log

2020/05/22

Maintain

2020/05/24 (Sunday)

nrelog_20200521.log

2020/05/21

Maintain

nrelog_20200522.log

2020/05/22

Maintain

2020/05/25 (Monday)

nrelog_20200521.log

2020/05/21

Delete file

nrelog_20200522.log

2020/05/22

Delete file

nrelog_20200525.log

2020/05/25

Create file

2020/05/26 (Tuesday)

nrelog_20200525.log

2020/05/25

Maintain

nrelog_20200526.log

2020/05/26

Create file

2020/05/27 (Wednesday)

nrelog_20200525.log

2020/05/25

Delete file

nrelog_20200526.log

2020/05/26

Maintain

nrelog_20200527.log

2020/05/27

Create file

Reading log files

The log files can be viewed using the appropriate operating system file explorer.

To implement the feature for viewing the log files within the app, obtain the path of the log file and read the contents of the file using the VirtualFile object.

Reading log files script example

This is an example of getting the first file stored in the corresponding path when the Button is clicked and displaying it in the TextArea component.

this.Button01_onclick = function(obj:Button,  e:nexacro.ClickEventInfo)
{
	var strLogpath = nexacro.getLogFilePath();
    this.VirtualFile00.getFileList( strLogpath, ".log", VirtualFile.findFileOnly );
}

this.VirtualFile00_onsuccess = function(obj:VirtualFile, e:nexacro.VirtualFileEventInfo)
{
	switch (e.reason)
	{
		case 1:	// open
			this.VirtualFile00.read();
			break;					
		case 3:	// read
			this.TextArea00.value = e.textdata;
			break;
		case 8:	// getFileList
			var logfilename = logpath + e.fileattributelist[0].filename;
			this.VirtualFile00.open(logfilename,  VirtualFile.openText);
			break;
	}
}

Restrictions in the Windows operating system

To access the log file in the Windows operating system, the environment filesecurelevel property value must be set to "all”. The sandbox window is displayed upon the initial run.