Logs
Logs directory
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
Default logging
Level
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
Loggers
console
: print logs with level greater thanDEBUG(10)
in stdoutfile
: 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
Exceptions
If an exceptions is catched by the WebScripts Server, it will be written in console
, file
and log_error
loggers.
Console
In console
logger i added terminal colors to quickly identify logs level:
DEBUG
logs are greenINFO
logs are blueACCESS
logs are cyanRESPONSE
logs are cyanCOMMAND
logs are cyanWARNING
logs are yellowERROR
logs are purpleCRITICAL
logs are red
File Rotation and compression
Log files rotate when the logs exceed 10MB and logs archive are compressed.
Linux
On linux WebScripts logs with level DEBUG
, INFO
, ACCESS
, RESPONSE
, COMMAND
, WARNING
, ERROR
and CRITICAL
are redirected in syslog.
Windows
On Windows if pywin32
is installed logs with level DEBUG
, INFO
, ACCESS
, RESPONSE
, COMMAND
, WARNING
, ERROR
and CRITICAL
are redirected in Windows Events.
Write logs in your own scripts
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.
Configuration
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.