Skip to content

Logging

Graham Steffaniak edited this page Jan 16, 2025 · 13 revisions

Logging Explainer Wiki

This version of filebrowser comes with a robust logger built-in that offers a variety of features.

Note: this requires v0.4.0 or later

Do I need to configure the logger?

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.

Can I log to a file?

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!

How do I configure a custom logger?

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 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
      noColors: true

Clone this wiki locally