Log-related settings

6   Log-related settings

< LogSetting type="object"> </LogSetting> The series of parameters between this pair of tags provides a complete log Parameter Settings, allowing the user to customize the output log to suit his own application.

6.1 Handling of crash logs

When the Application crashes, the daily log cannot record relevant information. Therefore, you need to open the crash log to record relevant information. The following two items are used to set the crash log:

l <DumpEnabled></DumpEnabled> Set whether to enable the crash log. There are two values for this parameter: true means enabled; false means not enabled.

l <DumpPath>./Dumps/</DumpPath> Sets the Export Directory of the crash log, which is a relative path, that is, a path relative to the SuperMap. XML 's own files.

6.2 Turn on/off the log function

<LogEnabled></LogEnabled> A parameter that controls whether the logging function is started automatically. The value of this parameter has two cases: true indicates that the log function is started automatically when the software is running; false indicates that the log function is started manually. The default is true

6.3 Log File Settings

6.3.1 Log file storage path

<LogFileLocation>./log</LogFileLocation> Set the storage location of the log file. If the directory is empty, it will be written to the Bin directory under the installation directory by default. The user can modify the storage location of the log file. For example, set the log file storage path to " D: \ Log ".

6.3.2 Log file storage method

<StorageType></StorageType> Controls how log files are stored. Text indicates that the log file is stored as a text file, and XML indicates that the log file is stored as an XML file. Memory indicates that the log file is stored in memory. The default is Text .

<LogPhysicalSave></LogPhysicalSave> Controls whether storage is performed according to the type specified by StorageType . true indicates that the storage is performed according to the type specified by StorageType , for example , StorageType = Text , The log file is stored as text; false means that the log file is stored in memory regardless of the type specified by the StorageType .

6.3.3 Log storage by file

Logs need to be stored in separate files when the following conditions exist.

l First, LogTimeInterval/LogTimeInterval Used to control the time interval of log file storage, The value of this parameter has five time types: None , Hour , Day , Week , Month None means to use a file for storage; Hour means to create a new log file for storage every hour; Day means to create a new log file for storage every other day; Week means to create a new log file for storage every other week; Month means to create a new log file for storage every other month. The default value is Day , which means that a new log file is created every other day by default.

Second, when the size of the log file exceeds < MaxFileSize >/MaxFileSize > When the size is specified, the log is stored in separate files according to the situation, as follows:

< MaxFileSize> </MaxFileSize> Used to control the size of the log file. If the size of the log file reaches MaxFileSize The system processes the log file with the root ExceedSizeMode. The type of MaxFileSize is long, and the unit is bit. If the MaxFile Size value is -1 , it indicates that there is no file size control.

When the size of the log file reaches the value of MaxFileSize, the system determines <ExceedSizeMode></ExceedSizeMode> To process the log file using the value of. There are three cases for this parameter value:

n Rolling indicates rollback processing, that is, overwriting from the current file header;

n ReOpen means to re-open File processing, that is, to empty the current file and then re-open it for writing;

n NewFile means to create a new file for recording. The new file name is the original file name + # 1, # 2 , # 3, and so on.

6.3.4 Log File File Name Rule

<LogFilePrefix>UGC</LogFilePrefix> Is the prefix of the log file name. The file name suffix is ".log" . The user can customize the prefix name, but the File Name cannot contain the following characters.

Question mark

?

Quotation marks

"

Slash

/

Backslash

\

Less than sign

<

Greater than sign

>

Asterisk

*

Vertical line

|

Colon

:

In addition , the log is not output to a single log file, The user can create a new log file to store the output Log Information according to the set time rule , that is, the rule of log sub-file storage.

<LogTimeInterval></LogTimeInterval> Used to control the time interval of log file storage, The value of this parameter has five time types: None , Hour , Day , Week , Month None means to use a file for storage; Hour means to create a new log file for storage every hour; Day means to create a new log file for storage every other day; Week means to create a new log file for storage every other week; Month means to create a new log file for storage every other month. The default value is Day , which means that a new log file is created every other day by default.

Therefore, the File Name of the log file also contains information related to the time interval at which the log subfile is stored. Details are as follows:

After starting the log file, first determine the value of LogTimeInterval :

LogTimeInterval = None

The name of the log file is: Prefix _ PID. Log ". If the value of MaxFileSize is set and the Exceed Size Mode = NewFile , When the size of the log file exceeds MaxFileSize , The files are named " prefix _ PID # 1.log" , " Prefix _ PID # 2.log" , " Prefix _ PID # 3.log".. , and so on. For example, UGC _ 2212 # 2.log indicates a prefix of UGC , The current PID is 2212 , # 2 indicates a tag for a new file that exceeds the MaxFileSize.

LogTimeInterval = WeekDayHour

The name of the log file is: "prefix _ PID _ date.log " . When the time interval exceeds the LogTimeInterval , The log File Name is " prefix _ PID _ date _ 1.log" , " prefix _ PID _ date _ 2.log" , " Prefix _ PID _ date _ 3.log".. And so on. If MaxFileSize is also set and Exceed SizeMode = NewFile , When the size of the log file exceeds MaxFileSize , Add # 1 , # 2, # 3.. , and so on. For example, the UGC _ 2212 _ 2007121914 _ 1 # 3.log indicates that the prefix is UGC , The new log file was created at 14 : The current PID is 2212 , and _ 1 is the tag added to the new file after the time interval. # 3 is the tag for a new file that exceeds MaxFileSize.

Notice

The date is accurate to the hour, that is, year, month, day and hour.

PID is the process identifier. On Windows , it can be viewed through the Windows Task Manager . In Windows Task Under the View menu in the Manager , Click Select Columns , Check PID (Process Identifier) to use Windows Task View the PID in the Manager window.

If the type of the log file is in XML format, replace.log with .xml .

During the use of UGC , the user can modify these parameters according to the actual situation. After saving, restart the Application to take effect. This article will explain some of the parameters that the user can customize.

6.3.5 Log Output Settings

<IsAppend>false</IsAppend> If the log file to be written exists, use IsAppend to control whether to continue appending to the current log file. The value of this parameter has two cases: true means to continue appending; false means to overwrite the original log file. The default is false .

How duplicate logs are handled

<IsFilter>false</IsFilter> Used to control whether duplicate logs are filtered. There are two values for this parameter: true means to filter duplicate logs, and false means not to filter duplicate logs. The default is false . For example, if 1000 identical operations are performed , each operation will output a " success " . If Is Filter is set to true , Only one " successful " record will be output, If Is Filter is set to false , 1000 Successes are output repeatedly.

Log output format

<LogFormat></LogFormat> Specifies the content of each log record in the log file. It is recommended not to modify the contents of the LogFormat . If you are an advanced user, you can modify it according to your own needs. For example, if you do not need to record the error level of the log in the log, you can delete "% Level ", or you can add Separator at will, such as brackets, braces, vertical bars, asterisks, etc. LogFormat Use " \ n " for carriage returns, " \ t " for tabs, and so on.

Example:

<LogFormat> %DATETIME| %TIMESPAN| %RESID| %THREADID| %LEVEL| %MSG| %CODEFILE(%CODELINE)</LogFormat>

Label

Explain

%DATETIME

The time and date of the

current log record in the format shown in DateTimeFormat

%TIMESPAN

Time interval between

two consecutive log records (

can be used for performance logging between two log records)

%LEVEL

Errors level of the

current record. Level type refers to LogLevel

.

%MSG

Description of the

log

%THREADID

The ID of the

thread

%CODEFILE

The file name of the code where the

error occurred

%CODELINE

The number of lines on which the code is in

error

 

< DateTimeFormat> </DateTimeFormat> Specifies the format of the date and time in the log file, where year, month, and day are represented by % Y ,% m , and % d , respectively. Hours, minutes and seconds are used separately. % H , % M and % S instead. The default date and time format is: year-month- day hour: minute: second. Advanced users can modify the date and time format according to their own habits.

Example:

<DateTimeFormat>%Y-%m-%d %H:%M:%S</DateTimeFormat>

Log output level

<LogLevel>error</LogLevel> Constant that defines the error logging level. The value of this parameter has two cases: debug is programmer-oriented and contains all information; error is user-oriented and contains Errors that may be caused by illegal operations. The default is error .

Log save frequency

<LogCountToDisk></LogCountToDisk> Controls how many entries of the log are written to disk once.

<LogCountInMemory></LogCountInMemory> Controls how many logs are saved in memory and then written to the log file.