Enables System Log Output As Text
Overview¶
This explains how to output the system log of Pleasanter as text.
Procedure¶
Parameter Change¶
To output the system log as text, edit the parameter settings to enable the function.
- Open App_Data/Parameters/SysLog.json.
- Set the "EnableLoggingToFile" parameter to "true".
- Restart Pleasanter.
For information on how to specify parameters, see "SysLog.json".
Detailed settings for log output¶
The system log output function itself uses NLog.
The output destination and content are set in appsettings.json.
The general configuration is as follows.
{
"Logging": {
"LogLevel": {
// ... Omitted
}
},
"NLog": {
"target": {
"jsonfile": {
"type": "File",
"fileName": "logs/${パス}/syslogs.json",
"layout": {
"type": "JsonLayout",
"Attributes": [
// ... Omitted
]
}
},
"csvfile": {
"type": "File",
"fileName": "logs/${パス}/syslogs.csv",
"layout": {
"type": "CsvLayout",
"columns": [
// ... Omitted
]
}
}
},
"rules": [
{
"logger": "syslogs",
"minLevel": "Info",
"writeTo": "csvfile"
}
]
}
}
| Column name | e.g. | Description |
|---|---|---|
| Logging | Omitted | Settings for ASP.NET Core log output level. |
| NLog | Omitted | NLog settings. |
| NLog.target | Omitted | Multiple output destination settings can be defined. *1 |
| NLog.target.jsonfile | Omitted | Settings for output in JSON format. |
| NLog.target.jsonfile.fileName | logs/${path}/syslogs.json | Specifies the output path and file name. |
| NLog.target.jsonfile.layout | Omitted | Specifies the items to be output. *2 |
| NLog.target.csvfile | Omitted | Settings for output in CSV format. |
| NLog.target.csvfile.fileName | logs/${path}/syslogs.csv | Specifies the output path and file name. |
| NLog.target.csvfile.layout | Omitted | Specifies the items to be output. |
| NLog.rules | Omitted | Specifies the log output destination. |
| NLog.rules.logger | syslogs | "syslogs" is the definition for syslog output. |
| NLog.rules.minLevel | Info | Specifies the log level to be output. |
| NLog.rules.writeTo | csvfile | Specifies the output destination. The default is CSV format. |
・ ※1: Targets | NLog
・ "fileName" : If it is a relative path, the same hierarchy as "App_Data" is used as the basis.
・※2: Layouts | NLog
・ CsvLayout · NLog/NLog Wiki
・ JsonLayout · NLog/NLog Wiki
Setting output column¶
We will explain the "layout" here.
The definition method differs for each "type", but by default, JSON and CSV formats are defined.
Common¶
The column output in both CSV and JSON formats are the same.
Also, columns specific to the text format are output before the contents of the SysLogs table.
・timestamp ‥ The date and time when the log was output. (It is not CreatedTime. It is possible not to output it.)
・level ‥ The level of the log. It has the same meaning as SysLogType in the SysLogs table.
・message ‥ The contents of the log. In the case of system logs, two types of messages are output.
・WriteSysLog ‥ Output when the DB is inserted.
・UpdateSysLog ‥ Output when the DB is updated.
・Two lines correspond to one system log record in the DB. The SysLogId is the same.
CSV format¶
The contents of the "SysLogs table" in the system log are output in CSV format.
"timestamp","level","message","CreatedTime","SysLogId",...,"Updator","UpdatedTime"
"2024-...","INFO","WriteSysLog","2024-...",9999,...,0,"DateTime"
1 system log is output on 1 line without line breaks.
JSON format¶
The contents of the "SysLogs Table" in the system log are output in JSON format.
{ "timestamp": "2024-...",..., "syslog": { "syslog": {"CreatedTime":"...", "SysLogId":999, ... "Updator":0, "UpdatedTime":"DateTime"} } }
{ ... }
{ ... }
・Each system log is output on a single line without line breaks.
・"syslog" outputs the contents of the SysLogs table converted directly to JSON format.
For details on the columns, please refer to FAQ: About the contents of the operation log (SysLogs table).