-
Notifications
You must be signed in to change notification settings - Fork 2
Logs
Create a directory named logs
to launch the WebScripts Server. If logs
directory does not exists or is not a directory, the WebScripts Server will try to create it.
mkdir logs
The logs level is "0" (all logs are written). You can change the logging level in configuration files or by using command line arguments.
Recommended: In production (for security reasons) the log level should be 0
or DEBUG
.
The WebScripts Server use six differents levels:
- Value:
50
, isCRITICAL
- Value:
40
, isERROR
- Value:
30
, isWARNING
- Value:
27
, isCOMMAND
- Value:
26
, isRESPONSE
- Value:
25
, isACCESS
- Value:
20
, isINFO
- Value:
10
, isDEBUG
- Value:
5
, isTRACE
-
console
: print logs with level greater thanDEBUG(10)
in stdout -
file
: write logs with level greater thanDEBUG(10)
inlogs/00-server.logs
-
log_trace
: write logsTRACE
inlogs/05-trace.logs
-
log_debug
: write logsDEBUG
inlogs/10-debug.logs
-
log_info
: write logsINFO
inlogs/20-info.logs
-
logger_access
: write logsACCESS
inlogs/25-access.logs
-
logger_response
: write logsRESPONSE
inlogs/26-response.logs
-
logger_command
: write logsCOMMAND
inlogs/27-command.logs
-
log_warning
: write logsWARNING
inlogs/30-warning.logs
-
log_error
: write logsERROR
inlogs/40-error.logs
-
log_critical
: write logsCRITICAL
inlogs/50-critical.logs
If an exceptions is catched by the WebScripts Server, it will be written in console
, file
and log_error
loggers.
In console
logger i added terminal colors to quickly identify logs level:
-
DEBUG
logs are green -
INFO
logs are blue -
ACCESS
logs are cyan -
RESPONSE
logs are cyan -
COMMAND
logs are cyan -
WARNING
logs are yellow -
ERROR
logs are purple -
CRITICAL
logs are red
Log files rotate when the logs exceed 10MB and logs archive are compressed.
On linux WebScripts logs with level DEBUG
, INFO
, ACCESS
, RESPONSE
, COMMAND
, WARNING
, ERROR
and CRITICAL
are redirected in syslog.
On Windows if pywin32
is installed logs with level DEBUG
, INFO
, ACCESS
, RESPONSE
, COMMAND
, WARNING
, ERROR
and CRITICAL
are redirected in Windows Events.
To group the logs you can use the following environment variable: LOG_PATH
. This is the path of the WebScripts logs. I recommend using the following path for your script: LOG_PATH/<script category>/<script name>.log
.
You can use the WebScriptsTools package to get the log file. It's possible to get it using command line or import it in python script. Read the README.md, you have some examples on this repository.
Caution: To protect your WebScripts server and your system is recommended to change the working directory permissions and owner (root:root 755
), your script can not create a file in script directory and working directory. You can not make a log file in the working directory or script directory.
The configuration can be edited, you can write your own configuration file, in ./config/logger.ini
, based on the WebScripts logger.ini. The WebScripts server use the default python logging library, get the documentation here.