I would like to know if it possible to pass env variable to the .confi file?
i add a custom handler like
[handler_customer_log]
class=logging.FileHandler
formatter=customer
args=(os.environ[logpath])
but i get an exception.
shouldn鈥檛 it be a string? which error do you get?
i am not sure..., i am trying to found how can i pass the log file name dynamically and not predefine as a string in args
@MatanTubul I don't think you can do that with logging configuration. You could, though, use a custom callable that returns a FileHandler
constructed as you need. Rather than specify class=logging.FileHandler
specify your own function that uses the environment variable to construct and return a file handler.
@MatanTubul what exception did you get? For sure anyway os.environ takes a string as a parameter. Like @tilgovi is saying you can set the logging configuration. About passing arguments, the old but still valid way is to give to the command line some shell variables and set them via a shell script or your launcher like supervisord, systemd...
@tilgovi thanks, i used your solution.
Most helpful comment
@tilgovi thanks, i used your solution.