-
Notifications
You must be signed in to change notification settings - Fork 404
Logging
This version of filebrowser comes with a robust logger built-in that offers a variety of features.
Note: this requires
v0.4.0or later
By default, if nothing is configured, the logger writes all INFO, ERROR, WARNING, and API events to the stdout with colors enabled.
The above default means you will see text logs in the terminal where you run the program like you would expect.
On windows or certain terminal prompts, colors may not work and you may see \033[0m text show up -- this indicates your terminal does not support colors and you would want to configure a logger with colors disabled to fix this.
Yes! You can log to a file or multiple different files each with their own settings. Do you want errors to go to errors.log or API event logs to go to apievents.log you can do that!
You can configure logging with the following format:
This would only log to file (not stdout)
server:
logging:
- output: "path/to/targetfile.log" # or "stdout"
level: "info" # or "debug", "error", "api"
This example would only log to stdout. (disables colors/api logs)
server:
logging:
- noColors: true
noApi: true
This example would log to terminal (without api events) and also send error-level logs to errors.log (except API errors) and api logs to api-events.log
server:
logging:
- output: stdout
noApi: true
- output: "api-events.log"
level: api
noColors: true
- output: "errors.log"
level: error
noApi: true
noColors: true
It depends. Log levels are hierarchical , meaning any level lower than the chosen will get logged.
Here are the levels:
DISABLED LogLevel = 0
ERROR LogLevel = 1
FATAL LogLevel = 1
WARNING LogLevel = 2
INFO LogLevel = 3
DEBUG LogLevel = 4
API LogLevel = 10
This means if you set your log level to ERROR, you will see only ERROR and FATAL logs, but nothing greater.
If you set your level to WARNING, you will see WARNING and ERROR/FATAL. And so on.
However, for API log level logs have their own special rules and you can specify exactly which API messages you want to log.