Dyn Logger
This crate provides a configuration option for the tracing logging crate,
allowing you to configure the logging based on a logging.toml
file. With this
file, you can easily change the log level per module, as well as the format and
other options for the logger. Additionally, the crate allows you to configure
multiple file loggers, each with its own log level, format, color, and path
options.
Usage
To use this crate, simply add it as a dependency to your Cargo.toml file:
[]
= "1.0"
Then, configure your logger as shown below. This will read the logging.toml file in your project's root directory, and apply the configuration settings to your tracing logger.
Configuration
The logging.toml file allows you to configure the logging options for your application. Here is an example:
# global logging options
[]
= "trace"
= false
= "compact" # Options: `full`, `compact`, `pretty` and `json`
= true
= true
= true
= true
# special std out logging, overrides global settings
[]
= true
= true
= "pretty" # Options: `full`, `compact`, `pretty` and `json`
= true
= true
= true
= true
= [
"module=trace",
"module::submodule_one=trace",
"module::submodule_two=debug",
"module::submodule_three=info",
]
# logging to files, uses global options
[[]]
= true
= "logfile.log"
= "./logs"
= false # override global options
= false # override global options
= "json" # Options: `full`, `compact`, `pretty` and `json`
= [
"module_name::submodule::example=trace",
]
[[]]
= true
= "another_logfile.log"
= "./logs"
= "compact" # Options: `full`, `compact`, `pretty` and `json`
= [
"module_name::submodule=trace",
"module_name::other_submodule=debug",
]
License
This crate is licensed under the EUPL-1.2 License. See the LICENSE file for more information.