-
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 logsThe 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 logsTRACEinlogs/05-trace.logs -
log_debug: write logsDEBUGinlogs/10-debug.logs -
log_info: write logsINFOinlogs/20-info.logs -
logger_access: write logsACCESSinlogs/25-access.logs -
logger_response: write logsRESPONSEinlogs/26-response.logs -
logger_command: write logsCOMMANDinlogs/27-command.logs -
log_warning: write logsWARNINGinlogs/30-warning.logs -
log_error: write logsERRORinlogs/40-error.logs -
log_critical: write logsCRITICALinlogs/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:
-
DEBUGlogs are green -
INFOlogs are blue -
ACCESSlogs are cyan -
RESPONSElogs are cyan -
COMMANDlogs are cyan -
WARNINGlogs are yellow -
ERRORlogs are purple -
CRITICALlogs 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.