-
Notifications
You must be signed in to change notification settings - Fork 11
Logging
This version of filebrowser comes with a robust logger built-in that offers a variety of features.
No need - 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 as you would expect.
Note: 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 its own settings. If 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"
levels: "info" # or "debug", "error", "warning"
This example would only log to stdout. (disables colors/api logs)
server:
logging:
- noColors: true
apiLevels: disabled
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
levels: info|warning|error # multiple allowed
apiLevels: disabled
- output: "api-events.log"
levels: disabled # disables logging regular events
noColors: true
- output: "errors.log"
levels: error|warning # only logs errors and warnings
apiLevels: disabled # don't log API stuff
noColors: true
Yes! You can specify exactly which logs you want to see, all of these are acceptable:
levels: info|warning error,debug # notice you can split by certain characters such as space or comma
apiLevels: "info|warning|error" # no debug level log for api
"FATAL" logs are considered errors, it's not a level you can specify. FATAL logs always print to console as well (there will only be one since it kills the program)
Not yet.
Debug logs are available by adding "debug" to the level config. These logs also print the exact line that caused the log events for all log types, not just debug.
There are two forms of loggers: stdout
and file
:
- A file output logger is defined by setting a file path using the
output
property. - A stdout logger is configured when the
output
property is unset or set tostdout
.
You can have as many file output loggers as you want, but there can only be 1 stdout logger.
If you try to configure more than one stdout logger (perhaps by not setting output), only the first stdout logger given will be used.